How the objective variable changes when analyzing time series data Visualize as a graph for checking in chronological order.
procedure
** ① Index the date column **
df.set_index('Date')
** ② Plot **
df.plot()
plt.xticks(rotation=70)
** ③ Undo for later processing **
df = df.reset_index()
date.py
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv('dataset.csv')
df.head()
"""output
patient Last UpDdated
0 5.0 2020-03-22 10:00:00
1 4.0 2020-03-22 11:00:00
2 6.0 2020-03-22 12:00:00
3 10.0 2020-03-23 10:00:00
4 3.0 2020-03-23 11:00:00
"""
#Index the date
df = df.set_index('Last UpDdated')
df.head(3)
"""output
Last UpDdated patient
2020-03-22 10:00:00 5.0
2020-03-22 11:00:00 4.0
2020-03-22 12:00:00 6.0
"""
#plot
df.plot()
#Change the angle of the X-axis label
plt.xticks(rotation=70)
date.py
#Return the index for later processing
df = df.reset_index()
df.head(3)
"""output
Last UpDdated patient
0 2020-03-22 10:00:00 5.0
1 2020-03-22 11:00:00 4.0
2 2020-03-22 12:00:00 6.0
"""
Recommended Posts