'how to check start range, end range, date range covered by data
i want to know how can i get the start date, end date and date range covered by data.
user_id gender address store_id trans_id timestamp item_id quantity dollar
0 101981 F E 2860 818463 2000-11-01 4.710000e+12 1 37
1 101981 F E 2861 818464 2000-11-01 4.710000e+12 1 17
2 101981 F E 2862 818465 2000-11-01 4.710000e+12 1 23
3 101981 F E 2863 818466 2000-11-01 4.710000e+12 1 41
4 101981 F E 2864 818467 2000-11-01 4.710000e+12 8 288
Solution 1:[1]
# Convert timestamp to pandas datetime object
df['timestamp'] = pd.to_datetime(df['timestamp'])
# Sort dataframe by date
df = df.sort_values(by='timestamp', ascending=False)
# Start date
print(df['timestamp'].min())
# End date
print(df['timestamp'].max())
# Date range is just between minimum and maximum
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | DerivativesTamer |
