如何在 Jupyter 中查找特定列中缺失数据的行数?数据集有大量行。
例如第1034行和第2045行有缺失数据,需要执行什么代码才能找到这些行?
代码适用于 Jupyter Notebook 或 Python 代码。
谢谢您的帮助!
根据我对您问题的理解,我认为以下代码示例可以帮助您:
import pandas as pd
# Read the dataset into a pandas DataFrame
df = pd.read_csv('your_dataset.csv')
# Specify the column name where you want to find missing data
column_name = 'your_column_name'
# Specify the range of rows to search within
start_row = 1034
end_row = 2045
# Find the row indices with missing data in the specified column within the range
missing_indices = df.loc[start_row:end_row, column_name[df.loc[start_row:end_row, column_name].isnull()].index.tolist()
# Print the row indices
print(missing_indices)