[英]Plotting a time series data
我有一個時間序列序列數據,其中一列是日期,第二列是代理的 ID。
pAgent Date Year Month Day Week-Day
0 27918 2019-11-28 2019 11 28 3
1 1286 2019-11-28 2019 11 28 3
2 1314 2019-11-28 2019 11 28 3
3 21342 2019-12-01 2019 12 1 6
4 5344 2019-11-28 2019 11 28 3
5 23841 2019-11-28 2019 11 28 3
6 22596 2019-11-28 2019 11 28 3
. .. ... .. .. .. ..
. .. ... .. .. .. ..
我如何繪制一個代理的出現,比如 pAgent = 22596,整整一個月?
import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame({'pAgent' :[22596,22596,44456,6655,22596,22596,42244,22596,22596,22596] ,'day': [1,2,3,4,5,6,7,8,9,10] })
fig, axes = plt.subplots(figsize=(10, 8))
axes.scatter(df[df['pAgent'] == 22596]['day'], df[df['pAgent'] == 22596]['pAgent'], marker = '|',s=10**3)
axes.set(xlabel='days')
fig.show()
有一個簡單的數據處理錯誤,我終於能夠解決它。 以下是該問題的解決方案:
count = file_name[file_name['pAgent'] == 27918].groupby("Day").count().reset_index()
plt.figure(figsize=(12,6))
ax = sns.pointplot("Day","pAgent",data=count,color="white",markers="H")
plt.axhline(avg_curr["pAgent"].mean(),color="k",
linestyle="dotted",linewidth=2,label="average transaction flow")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.