python - changing column types of a pandas data frame -- finding offending rows that prevent casting -


my pandas data has columns read objects. want change these floats. following post linked below (1), tried:

pdos[cols] = pdos[cols].astype(float) 

but pandas gives me error saying object can't recast float.

valueerror: invalid literal float(): 17_d

but when search 17_d in data set, tells me it's not there.

>>> '17_d' in pdos  false 

i can @ raw data see what's happening outside of python, feel if i'm going take python seriously, should know how deal sort of issue. why doesn't search work? how search on objects strings in pandas? advice?

pandas: change data type of columns

of course does, because you're looking in column list!

'17_d' in pdos 

checks see if '17_d' in pdos.columns

so want pdos[cols] == '17_d', give truth table. if want find row is, can (pdos[cols] == '17_d').any(1)


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -