简体   繁体   English

熊猫根据行,列和日期过滤DataFrame

[英]Pandas filter DataFrame based on row , column and date

Everyone. 大家。
I am trying to filter data based on row name , column and date based. 我正在尝试基于行名称,列和日期来过滤数据。 I have data as you can see in image below, I am scraping html table using selenium. 我有数据,如下图所示,我正在使用Selenium抓取html表。

Data I have 我有数据

在此处输入图片说明

complete code : 完整的代码:

https://repl.it/@AshfaqueMarfani/DroopyDismalCubase

I want to filter data like this. 我想这样过滤数据。

argument : date 2018-11-10 to 2018-12-1
2018-11-10 | Total Issues Traded | 8243
2018-11-11 | Total Issues Traded | 8232
2018-11-12 | Total Issues Traded | 90000
2018-11-13 | Total Issues Traded | 10000
2018-11-14 | Total Issues Traded | 8243

Try this: 尝试这个:

df[(df.0 == "Total Issues Traded")]

OR 要么

df.loc[df['0'] == "Total Issues Traded"]

OR 要么

df.loc[df['0'] == "Total Issues Traded" & df['date'] > '2018-11-09') & (df['date'] < '2018-12-02')]

Let me know if this is what you want or you need some changes 让我知道这是您想要的还是需要一些更改

If i understood your question correctly, you want to filter by date and by value of the first column in your dataframe. 如果我正确理解了您的问题,则希望按日期和数据框中第一列的值进行过滤。 One of the ways to achieve it is the following: 实现此目标的方法之一如下:

df[df['date'].between('2018-11-10', '2018-12-01')&(df[0]=='Total Issues Traded')]

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

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