Pandas Dataframe Sort On Column Raises Keyerror On Index
I have the following dataframe, df: peaklatency snr 0 52.99 0.0 1 54.15 62.000000 2 54.12 82.000000 3 54.64 52.000000 4 54.5
Solution 1:
The by
keyword to sort_values
expects column names, not the actual Series itself. So, you'd want:
In [23]: df.sort_values('snr')
Out[23]:
peaklatency snr
0 52.99 0.0
4 54.57 42.0
3 54.64 52.0
1 54.15 62.0
5 54.13 72.0
2 54.12 82.0
Post a Comment for "Pandas Dataframe Sort On Column Raises Keyerror On Index"