January 15, 2020
I want to get the date (when it is first seen)
the date of the last seen.
I tried :
df[0]
df['First Seen'].max()
but nothing.
A:
I think need compare by first column and first max value per group, aggregate DateFrame.first_valid_index, but maybe is better create GroupBy.first, so working solution is:
df1 = df.groupby('User ID', group_keys=False).first()
print (df1)
Date User ID
0 2019-10-01 1029
1 2019-10-01 1029
2 2019-10-01 1029
3 2019-10-01 1029
4 2019-10-01 1029
5 ac619d1d87
Related links:
Commentaires