问题遇到的现象和发生背景
不知道为什么一直报错,我看别人在date的处理上也是这样几步呀
/usr/local/lib/python3.9/site-packages/pandas/core/arrays/datetimelike.py:1189: PerformanceWarning: Adding/subtracting object-dtype array to TimedeltaArray not vectorized.
warnings.warn(
用代码块功能插入代码,请勿粘贴截图
import pandas as pd
from datetime import timedelta
df = pd.read_csv("nowcoder.csv")
df["date"] = pd.to_datetime(df["date"]).dt.date
df["date_number"] = pd.to_timedelta(df.groupby("user_id")["date"].rank(), unit="d")
df["date_diff"] = df["date"] - df["date_number"]
result = df.groupby(["user_id", "date_diff"]).count().groupby("user_id").max()
print(result[result >= 3])
运行结果及报错内容
/usr/local/lib/python3.9/site-packages/pandas/core/arrays/datetimelike.py:1189: PerformanceWarning: Adding/subtracting object-dtype array to TimedeltaArray not vectorized.
warnings.warn(