I have a pandas data frame containing two datetime columns that contain the dates that a user joined a forum, and the date when said user posted a comment.
I am looking to subtract the date_joined column from the date_of_post column with the resulting new column containing the difference between the dates represented as the number of days .
I have tried running the following code:
df_combined['age'] = (df_combined['time_of_post'] - df_combined['date_joined']).dt.days
Though this encounters an error message:
TypeError: unsupported operand type(s) for -: 'Timestamp' and 'str'
My data frame looks something like this:
user_name | thread_name | post_text | time_of_post | date_joined | binary_target |
---|---|---|---|---|---|
BoxCutter | It's Okay When We Do It. | ..... | 2022-08-09 | 2022-05-26 | 1 |
Docket_33 | It's Okay When We Do It. | ..... | 2022-08-09 | 2022-06-10 | 1 |
Hearmeout | It's Okay When We Do It. | ..... | 2022-08-09 | 2021-10-07 | 0 |
Any help would be greatly appreciated!