简体   繁体   English

每小时数据到每日数据python

[英]Hourly data to daily data python

I have hourly data as shown.我有如图所示的每小时数据。 I want to convert hours to date.我想将小时数转换为日期。 How can I do it?我该怎么做?在此处输入图片说明

I didn't quite understand the question as a simple matter to count a date you need a start point to start counting.我不太明白这个问题是计算日期的简单问题,您需要一个起点来开始计数。 I can say there has been 24 since I started counting what date is it but if I won't say when I started counting nobody can know what date is it.我可以说自从我开始数它是什么日期以来已经有 24 次了,但是如果我不说我什么时候开始数,那么没有人知道它是什么日期。

But assuming you have a start point it becomes simple, take the hours for each start point and divide by 24, you'll get the days and leftover hours, and then add them to your start date and this way you'll get date and time.但是假设你有一个起点,它变得很简单,把每个起点的小时数除以 24,你会得到天数和剩余的小时数,然后将它们添加到你的开始日期,这样你就会得到日期和时间。

I am sorry if I did not understand you correctly, but this is the best I've realized from your question.如果我没有正确理解你,我很抱歉,但这是我从你的问题中意识到的最好的。 Hope it helps :)希望能帮助到你 :)

Example: Start Point: 10/02/2020, Time: 00:00AM Hours: 354 hours End Point: 10/02/2020 + 354 hours = 10/02/2020 + 14 days + 18 hours = (24/02/2020, 6:00PM)示例:起点:10/02/2020,时间:00:00AM 小时:354 小时 终点:10/02/2020 + 354 小时 = 10/02/2020 + 14 天 + 18 小时 = (24/02/2020 , 下午 6:00)

I was also looking for the same solution.我也在寻找相同的解决方案。 Below code might help下面的代码可能有帮助

在此处输入图片说明

After resampling the data looks as below.重采样后的数据如下所示。 In the code I am doing cumulative 6 hours sum up.在代码中,我正在做累计 6 小时的总结。

df.resample('6H', on = 'Hour').sum()

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python:使用 ffill() 将数据帧从每日数据上采样到每小时数据 - Python: upsampling dataframe from daily to hourly data using ffill() 将quandl fx每小时数据转换为每日 - Convert quandl fx hourly data to daily 将每日数据重新采样为每小时数据框并复制内容 - Resample daily data to hourly dataframe and copy contents 过滤每小时数据python - filter hourly data python 在 Python 中使用每小时数据的 SARIMA - SARIMA with hourly data in Python 将Pandas datetimeindex的频率从每天更改为每小时,以根据每日重采样数据的条件选择每小时数据 - Change the frequency of a Pandas datetimeindex from daily to hourly, to select hourly data based on a condition on daily resampled data Python Map Reduce 从每小时数据中查找每个气象站的每日最高、最低、平均和温度变化 - Python Map Reduce to find daily max, min, mean and variance in temperature for each weather station from hourly data 如何从 Python 中的每小时数据 netcdf 文件中找到最高日温度? - How to find maximum daily temperature from hourly data netcdf file in Python? Python pandas 将瞬时每小时数据重新采样到每日时间步长,包括第二天的 00:00 - Python pandas resampling instantaneous hourly data to daily timestep including 00:00 of next day 熊猫:从csv的每日数据生成每小时数据 - Pandas: Generating hourly data from daily data from csv
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM