Python Dataframe.resample () remove time from datetimeindex

For some reason, oversampling to 24H or 1D breaks the time from DateTimeIndex.

I am using python: 3.5.3 / conda numpy: 1.11.3 pandas: 0.20.2

df = pd.read_csv(inFile, parse_dates=True)

print(df.head())
df = df.resample("1D").agg({'open':'first','high':'max','low' :'min','close': 'last','volume': 'sum'}).dropna()

print(df.head()

      

First print instruction

enter image description here

Second

enter image description here

+3


source to share


1 answer


It revealed



df.index = pd.to_datetime(df.index.format(formatter=lambda x: x.strftime('%Y-%m-%d %H:%M:%S'))) 

      

0


source







All Articles