python - How to calculate the max click interval using pandas? -
i have dataset indicates when ip click link:
ip time
i want calculate maximum click interval of every different ip.
is there anyway this?
if understand question, you're looking following.
import pandas pd df = pd.dataframe({'ip':[1,1,1,1,1,2,2,2,2], 'time':pd.date_range('01-15-16 12:00:00', periods=9)}) df_grp = df.groupby('ip')['time'].apply(lambda x: x.max() - x.min())
this calculates time difference between first , last clicks associated ip.
Comments
Post a Comment