简体   繁体   English

得到平均 Python

[英]Getting an average Python

Basically, I have two csv files.基本上,我有两个 csv 文件。 One is the file located here ( https://ourworldindata.org/covid-cases ).一个是位于此处的文件 ( https://ourworldindata.org/covid-cases )。 The other is from a bot that runs and grabs hospital wait times.另一个来自运行并获取医院等待时间的机器人。 It looks like this: Picture of CSV File .它看起来像这样: CSV 文件的图片 I'm focusing on Georgia Hospitals specifically, which I know which ones it's recording, but I'm having problems with averaging the wait time across the state each day.我特别关注佐治亚医院,我知道它在记录哪些医院,但我在平均每天 state 的等待时间时遇到了问题。 I've tried a few different things, but I'm not too familiar with Python. I'm trying to balance it between two different files so that I can compare new cases with wait times.我尝试了几种不同的方法,但我对 Python 不太熟悉。我试图在两个不同的文件之间取得平衡,以便我可以比较新案例和等待时间。 How would I get a list of the average wait times per day for the hospitals in a specific region?我如何获得特定地区医院每天平均等待时间的列表?

import pandas as pd

df = pd.read_csv('file.csv')
df['datetime'] = pd.to_datetime(df['Date'])
average_wait_time = df.groupby(df.datetime.dt.date)['Wait_Time'].mean()

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM