熊猫-删除时间戳

时间:2020-09-02 12:29:09

标签: python-3.x pandas datetime

我正在尝试使用熊猫计算基本统计信息。我具有从1956年开始的整年的沉淀值。我创建了一个“日期”列,该列使用pd.date_range表示了整年的日期。然后,我计算了年份的最大值和最大值的日期。最大值的日期显示为“ Timestamp('1956-06-19 00:00:00”作为输出。如何仅提取日期。我不需要时间戳或00:00:00时间

#Create Date Column
year = 1956
start_date = datetime.date(year,1,1)
end_date = datetime.date(year,12,31)
precip_file["Date"] = pd.date_range(start=start_date,end=end_date,freq="D")

#Yearly maximum value and date of maximum value
yearly_max = precip_file["Precip (mm)"].max(skipna=True)
max_index = precip_file["Precip (mm)"].idxmax()
yearly_max_date = precip_file.iat[max_index,2

Image of output dictionary I am trying to create

1 个答案:

答案 0 :(得分:0)

可能与this问题重复,尽管我不能告诉您是要转换一个DateTime还是转换DateTimes列。