Tuesday, 15 July 2014

python 2.7 - Creating a pandas.DataFrame from a dict -



python 2.7 - Creating a pandas.DataFrame from a dict -

i'm new using pandas , i'm trying create dataframe historical weather data.

the keys day of year (ex. jan 1) , values lists of temperatures days on several years.

i want create dataframe formatted this:

... jan1 jan2 jan3 etc 1 temp temp temp etc 2 temp temp temp etc etc etc etc etc

i've managed create dataframe dictionary

df = pandas.dataframe(weather)

but end 1 row , ton of columns.

i've checked documentation dataframe , dataframe.from_dict, neither extensive nor provided many examples.

given "the keys day of year... , values lists of temperatures", method of construction should work. example,

in [12]: weather = {'jan 1':[1,2], 'jan 2':[3,4]} in [13]: df = pd.dataframe(weather) in [14]: df out[14]: jan 1 jan 2 0 1 3 1 2 4

python-2.7 pandas

No comments:

Post a Comment