2017-07-17 126 views
2
1天

日期過我注意到,如果我有一個數據幀熊貓熊貓的內部日期時間指數,當我使用.value的熊貓數據幀由

舉例稱他們的日期的價值變化。

import pandas as pd 

date_try=pd.date_range(start='2017-01-01',end='2017-05-01',freq='MS') 
date_df=pd.DataFrame(date_try) 

print(date_df) 

enter image description here

現在通知的日期值如何變化,當我打電話

print(date_df.values) 

enter image description here

+0

你有什麼版本的熊貓?我無法在0.20 –

+0

上重現這一點 - 這就是Numpy如何顯示日期時間的... – MaxU

+0

我的版本是0.15.2,並且我僅限於使用此版本。 –

回答

2

@DYZ是正確的,我碰到這一切的時候上設置cronjobs我的aws盒,它運行的時間與源文件所說的時間不一致,因爲它是在不同的時區產生的。你c嘗試在當地時間重新編制索引。

import pytz 
eastern = pytz.timezone('US/Eastern') 
df.index = index.tz_localize(pytz.utc).tz_convert(eastern)