【发布时间】:2022-01-17 02:52:43
【问题描述】:
使用python和pandas,我想实现下面的输出。只要文件中存在Null 或Nan 值,则需要打印行号和列名。
import pandas as pd
# List of Tuples
employees = [('Stuti', 'Null', 'Varanasi', 20000),
('Saumya', 'NAN', 'NAN', 35000),
('Saumya', 32, 'Delhi', 30000),
('Aaditya', 40, 'Dehradun', 24000),
('NAN', 45, 'Delhi', 70000)
]
# Create a DataFrame object from list
df = pd.DataFrame(employees,
columns =['Name', 'Age',
'City', 'Salary'])
print(df)
预期输出:
Row 0: column Age missing
Row 1: Column Age, column City missing
Row 4: Column Name missing
【问题讨论】:
标签: python python-3.x pandas dataframe csv