I have a python dictionaries where the key is a dateobject and the value is the timeseires.
timeseries = {datetime.datetime(2013, 3, 17, 18, 19): {'t2': 400, 't1': 1000},
datetime.datetime(2013, 3, 17, 18, 20): {'t2': 300, 't1': 3000}
}
How to I get this time series into a pandas dataframe?
use DataFrame.from_dict
:
import pandas as pd
import datetime
timeseries = {datetime.datetime(2013, 3, 17, 18, 19): {'t2': 400, 't1': 1000},
datetime.datetime(2013, 3, 17, 18, 20): {'t2': 300, 't1': 3000}
}
print pd.DataFrame.from_dict(timeseries, orient="index")
output:
t2 t1
2013-03-17 18:19:00 400 1000
2013-03-17 18:20:00 300 3000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With