Python 数据帧索引中无

Python 数据帧索引中无,python,pandas,indexing,Python,Pandas,Indexing,我正在将一个sql查询读入一个数据帧,并使用其中一列作为数据帧的索引。问题是查询没有过滤空值,结果数据帧中的某些行的索引为None。我可以想出几种方法来解决这个问题,但我想知道是否已经存在一些熊猫代码来处理这个问题,比如: import pandas as pd pd.Index().dropna() 我知道那不行:-)我已经试过了。还有什么吗?我会推迟设置索引,直到您删除NA值: cnn = get_db_connection() sqlqry = "select * from table"

我正在将一个sql查询读入一个数据帧,并使用其中一列作为数据帧的索引。问题是查询没有过滤空值,结果数据帧中的某些行的索引为None。我可以想出几种方法来解决这个问题,但我想知道是否已经存在一些熊猫代码来处理这个问题,比如:

import pandas as pd
pd.Index().dropna()

我知道那不行:-)我已经试过了。还有什么吗?

我会推迟设置索引,直到您删除NA值:

cnn = get_db_connection()
sqlqry = "select * from table"
nacols = ['Col_with_NAs']
indexcols = ['Col_with_NAs', 'othercol1', 'othercol2']
df = pandas.read_sql(sqlqry, cnn).dropna(subset=nacols).set_index(indexcols)

我会推迟设置索引,直到您删除NA值:

cnn = get_db_connection()
sqlqry = "select * from table"
nacols = ['Col_with_NAs']
indexcols = ['Col_with_NAs', 'othercol1', 'othercol2']
df = pandas.read_sql(sqlqry, cnn).dropna(subset=nacols).set_index(indexcols)

我会推迟设置索引,直到您删除NA值:

cnn = get_db_connection()
sqlqry = "select * from table"
nacols = ['Col_with_NAs']
indexcols = ['Col_with_NAs', 'othercol1', 'othercol2']
df = pandas.read_sql(sqlqry, cnn).dropna(subset=nacols).set_index(indexcols)

我会推迟设置索引,直到您删除NA值:

cnn = get_db_connection()
sqlqry = "select * from table"
nacols = ['Col_with_NAs']
indexcols = ['Col_with_NAs', 'othercol1', 'othercol2']
df = pandas.read_sql(sqlqry, cnn).dropna(subset=nacols).set_index(indexcols)

如何
df.reset_index()
?如何
df.reset_index()
?如何
df.reset_index()
?如何
df.reset_index()