sparrow sparrow - 1 year ago 139
Python Question

Unable to get min value of DataFrame column with Pandas

I'm trying to get the min value of values in a column of times. If I take a subset of the data I'm able to do it:


output is returned correctly:


But if I try on the entire column this error is returned:



TypeError: unorderable types: str() <= float()

So there is some bad data that is tripping up the min method. Is there any way to call the method and skip the bad data?

Answer Source

It seems to me that you have both floats and strings in that one column.

See if this works:


If it does, then you also have floats in that column. You want to find them and deal with them.

my_floats_indices = [i for i, v in df7['START_TIME'].iteritems() if isinstance(v, float)]

Then look at them with

df7.loc[my_floats_indices, 'START_TIME']

See if you can fix your problem. Hope that helps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download