python - None in pandas dataframe index -


i'm reading sql query dataframe , utilizing 1 of columns index of dataframe. problem query did not filter nulls , resulting dataframe has rows in index none. can think of several ways fix this, wondering if pandas code existed took care of like:

import pandas pd pd.index().dropna() 

i know doesn't work :-) tried already. there else?

i hold off on setting index until after you've dropped na values:

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

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -