I am using the below to create a dataframe using Pandas on Python 2.7. How to I get utcdt to be the time series index?
data_hash = {u'impressions': 105.0, u'campaign_id': u'cid2504649263', 'utcdt': datetime.datetime(2013, 10, 29, 18, 0)}
df = pd.DataFrame.from_dict(data_hash, orient="index")
You should transpose the dataframe first before setting the index:
df.T.set_index('utcdt')
Out[133]:
impressions campaign_id
utcdt
2013-10-29 18:00:00 105 cid2504649263
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.