我需要在列中出现某个值以与时间戳匹配(pandas dataframe& csv-file)
我有一个带有列roomid的CSV文件(称为“ Cameradata”),时间(还有更多的列,但不需要它们)。
我想在一天中使用某个会议室内的事件数量(“ 14094020”(“ 14094020”)。幸运的是,CSV文件仅由“时间”专栏中一天的时间戳组成。一个问题是时间戳在DateTime-Format%H:%m:%s中,我想在发生的小时(07:00-18:00)之前对出现进行分类。
目的是将出现与时间戳的时间链接在一起 - 为了让我绘制一个带有(x =“ Timestamps(hourly)”的barplot,y =“ y =”一个数据框/系列,将某个会议室绘制为一小时 。
使用
了
y = cameradata.set_index('Time').resample('H')
cameradata['MeetingRoomID'].value_counts()[14094020]
被 我不知道如何以语法友好的方式连接它
,但
。揭示了最多的ID,所以我认为我对
的帮助表示感谢!
您 是我所说的geetsroomid。 出于某种原因,“时间”列将其转换为DateTime时添加了一个化妆的年份和一个月。我转换为DateTime:Kameradata ['tid'] = pd.to_dateTime(kameradata ['tid'],格式=('%h:%m:%s'))
I have a csv-file (called "cameradata") with columns MeetingRoomID, and Time (There are more columns, but they should not be needed).
I would like to get the number of occurrences a certain MeetingRoomID ("14094020", from the column "MeetingRoomID") is used during one day. The csv-file luckily only consist of timestamps from one day in the "Time" column. One problem is that the timestamps are in the datetime-format %H:%M:%S and I want to categorize the occurrences by the hour it occured (between 07:00-18:00).
The goal is to have the occurences linked to the hours of the timestamps - in order for me to plot a barplot with (x = "timestamps (hourly)" and y = "a dataframe/series that maps the certain MeetingRoomID with the hour it was used".
How can I get a function for my y-axis that understands that the value_count for ID 14094020 and the timestamps are connected?
So far I've come up with something like this:
y = cameradata.set_index('Time').resample('H')
cameradata['MeetingRoomID'].value_counts()[14094020]
My code seems to work if I divide it, but I do not know how to connect it in a syntax-friendly way.
Clarification:
The code: cameradata['MeetingRoomID'].value_counts().idxmax()
revealed the ID with the most occurrences, so I think I'm onto something there.
Grateful for your help!
This is how the print of the Dataframe looks like, 'Tid' is time and 'MätplatsID' is what I called MeetingRoomID.
For some reason the "Time" column has added a made-up year and month next to it when I converted it to datetime. I converted in to datetime by: kameradata['Tid'] = pd.to_datetime(kameradata['Tid'], format=('%H:%M:%S'))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论