python - KeyError when data encoded as string -


after struggle plotting code, end following minimal working example:

import pandas import matplotlib.pyplot plt  data = {     'foo': ['2', '335', '3'],     'bar': [1, 2, 1], }  pandas.dataframe(data).plot.scatter('foo', 'bar')  # keyerror plt.show() 

which raise keyerror: 'foo'.

however, if use integers in foo data instead of strings:

'foo': [2, 335, 3], 

i expected scatterplot, without error.

what rationale dataframe behavior ? can understand data must in same format. why raise (very laconic) keyerror in case ?


Comments

Popular posts from this blog

cron - how to properly run Python script with crontab on every system startup -

elasticsearch - Is the order of operations guaranteed in a bulk update? -

Slow performance first queries on SQL Azure -