0

I have a dataset having only timestamps

 2021-12-07 23:27:25.090794+00
 2021-12-07 23:27:46.082402+00
 2021-12-07 23:27:57.190628+00
 2021-12-07 23:28:28.070957+00
 2021-12-07 23:27:55.029006+00
 2021-12-07 23:28:00.854966+00

and I want to plot the number of hits (let's say per minute or per 10-minute) over running time? (Considering each of these timestamps as a hit)

Is there an easy way to do this (preferably using plotly since it's interactive)

plot

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
Saif
  • 2,530
  • 3
  • 27
  • 45
  • Does the number of hits refer to how often the time occurs, and the value on the y-axis is an integer? – r-beginners Dec 08 '21 at 03:43
  • @r-beginners yes. So, for a minute-long interval, we might have y number of events. x: time, y: integer – Saif Dec 08 '21 at 03:44

1 Answers1

1

I don't know how much of this data is the same as the data you have, but I created a time series of data on the order of 1 millisecond and performed a random selection of it. The data was then downsampled by one minute, and the frequency was calculated.

import pandas as pd
import numpy as np
#import plotly.graph_objects as go
import plotly.express as px

date_range = pd.date_range('2021-12-07 00:00:00','2021-12-07 03:00:00', freq='1ms')
df = pd.DataFrame({'timestamp':np.random.choice(pd.to_datetime(date_range), 500), 'values':[1]*500})
df.set_index('timestamp', inplace=True)
df = df.resample('1min').count()
df.reset_index(inplace=True)

px.line(df[:35], x='timestamp', y='values', markers=True, title='Hits per Second')

enter image description here

r-beginners
  • 31,170
  • 3
  • 14
  • 32