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

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -