Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用以下内容在 Python 2.7 上使用 Pandas 创建数据框。如何让 utcdt 成为时间序列索引?
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")
在设置索引之前,您应该先转置数据帧:
df.T.set_index('utcdt') Out[133]: impressions campaign_id utcdt 2013-10-29 18:00:00 105 cid2504649263