Reputation: 129
I am trying to plot a smooth curve with x-axis being time of the day and y-axis is number of login attempts, I have the number of login attempts and the time of the attempts in a Counter which is converted into a panda dataframe, I am using the following code, but it doesn't generate the required graph
d = Counter(times)
key = d.keys()
df = pd.DataFrame(d, key)
df.drop(df.columns[1:], inplace=True)
df.plot()
plt.show()
This in turn produces the following graph
Upvotes: 0
Views: 471
Reputation: 15588
Visualization of data is quite unintuitive when using libraries like matplotlib, seaborn, bokeh and the like. Thank’s to Jake VanderPlas, there exists Altair, a declarative libraries that is very straight forward. Just load your not aggregate date data to df.Assuming you have one column of non-aggregated dates you could do:
#pip install altair
import altair as alt
alt.Chart(df).transform_aggregate(
count='count()',
groupby=['date']
).mark_line().encode(
x='date',
y='count()',\
tooltip='count:Q'
)
Upvotes: 0