0

My dataframe contains messages from a chat in chronological order, here is a three message preview:

                          timestamp  fromMe                                              text weekday week        time_diff len  is_new_convo
0     2018-04-23 19:50:25+00:00   False                  No but i like the other one more         0    17  0 days 00:00:00  8.0         False
1     2018-04-23 19:50:30+00:00    True                  Really though?                           0    17  0 days 00:00:05  2.0         False
2     2018-04-23 19:54:49+00:00    True                  Well i dont agree anyway                 0    17  0 days 00:04:19  5.0         False

Now I want to plot the time it takes for the two people to answer to the previous message (against time of the day, weekday, month etc. to see when they are the most active), but it should not plot the messages where "is_new_convo" is true because those don't count (it is true if time_diff exceedes 15 minutes).

Basically i want to plot a pandas dataframe with matplotlib, but only the rows that satisfy a condition. How do I do this?

Hans
  • 11
  • 3
  • 2
    Think about it this way ... How can you transform the data frame, using pandas, so that there is a column with the data you need and only the tried that match your condition? All matplotlib would be used for is plotting the result. Everything else is done with pandas commands. – Matt L. Nov 29 '20 at 17:25
  • Welcome to SO. This isn't a discussion forum or tutorial. Please take the [tour] and take the time to read [ask] and the other links found on that page. Invest some time with [the User Guide](https://pandas.pydata.org/docs/user_guide/index.html) practicing the examples. Eventually you'll get to the section regarding indexing/selecting data. – wwii Nov 29 '20 at 17:26
  • Related: [How to select rows from a DataFrame based on column values](https://stackoverflow.com/questions/17071871/how-to-select-rows-from-a-dataframe-based-on-column-values). ... A few others searching with `python pandas select rows based on condition site:stackoverflow.com`. – wwii Nov 29 '20 at 17:29

0 Answers0