Subtracting Two Dates From Columns In 2 Dataframes Pandas
I have the following code: for tup in unique_tuples: user_review = reviews_prior_to_influence_threshold[(reviews_prior_to_influence_threshold.business_id == tup[0]) & (revi
Solution 1:
The dates in your dataframe are likely not datetime64 dtype
instances, hence the invalid type comparison
. You can check with df.dtypes
. If that's true, use df.date = pd.to_datetime(df.date)
.
You likely have some dates in your dataframe that are null
, hence the comparisons vs. "None". Use df[pd.notnull(df.dates)]
.
BTW: Subtracting the dates should get you timedelta
so you'll likely need to do something like (friend_review.date - user_review.date).dt.days <= 62
.
Post a Comment for "Subtracting Two Dates From Columns In 2 Dataframes Pandas"