[英]Filter data in CSV read in Pandas
I have this CSV to read, but I need to filter the groupby values by column 'State' where 'Updated On' values is 24/04/2021, but I don't know how.我有这个 CSV 可供阅读,但我需要按“状态”列过滤 groupby 值,其中“更新时间”值为 24/04/2021,但我不知道如何。
acoesEstado = pd.read_csv("https://api.covid19india.org/csv/latest/statewise_tested_numbers_data.csv", index_col=0)
filtro = acoesEstado.groupby(['State']).sum(Updated On = '25/04/2021').reset_index()
filtro['Total Tested']
I want the output: select all States where Updated On = 24/04/2021我想要 output: select 所有更新在 = 24/04/2021 的州
If you are looking for Sum of Total Tested by State for 24/04/2021.如果您正在寻找 2021 年 4 月 24 日 State 测试的总和。
df.loc['24/04/2021'].groupby('State')['Total Tested'].sum()
Considering Input:考虑输入:
df = pd.read_csv("https://api.covid19india.org/csv/latest/statewise_tested_numbers_data.csv", index_col=0)
**Sample Output: **样品 Output:
State
Andaman and Nicobar Islands 0.0
Andhra Pradesh 15931722.0
Arunachal Pradesh 434293.0
Assam 8240455.0
Bihar 25852574.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.