import pandas as pd
df = pd.read_csv('filename.csv', parse_dates=["date_col"], index_col="date_col")
df = df["1960-01-01":"1969-12-31"] # Subsetting for smaller portion
sub_df = df['1960':'1970'] # Slicing using time index
ax = sub_df.plot(color='blue', figsize=(12, 5), fontsize=12, linewidth=3, linestyle='--')
ax.set_xlabel('X label')
ax.set_ylabel('Y label')
ax.axvline('1969-01-01', color='red', linestyle='--') # Vertical Line, uses time index
ax.axhline(4, color='green', linestyle='--') # Horizontal Line, uses y value
ax.axvspan('1964-01-01', '1968-01-01', color='red', alpha=0.3) # Vertical region, uses time index range
ax.axhspan(8, 6, color='green', alpha=0.3) # Horizontal region, uses y value range
df_summary = sub_df.describe()
# Attach information table with the plot
ax.table(cellText=df_summary.values,
colWidths=[0.3]*len(df.columns), # Specify width of the table
rowLabels=df_summary.index, # Specify row labels
colLabels=df_summary.columns, # Specify column labels
loc='top') # Specify location of the table in the plot
rolling_mean = df.rolling(window=52).mean()
# Other types of plots
df.plot(kind='hist', bins=100) # other types include 'kde', 'box' etc
# Auto-correlation
from statsmodels.graphics import tsaplots
fig = tsaplots.plot_acf(df['col'], lags=40)
# Partial Auto-correlation
from statsmodels.graphics import tsaplots
fig = tsaplots.plot_pacf(co2_levels['co2'], lags=40)
# Multiple time series on same plot
fig, ax = plt.subplots()
ax.plot(df.index, df['col1'], color='red')
ax.tick_params('y', colors='red')
ax.set_xlabel('Time Axis')
ax.set_ylabel('First Y Axis')
ax2 = ax.twinx() # Same x axis, but separate y axis
ax2.plot(df.index, df['col2'], color='blue')
ax2.tick_params('y', colors='blue')
ax2.set_ylabel('Second Y Axis')
ax2.annotate("Annotation text", xy=(pd.Timestamp('2015-10-06'), 1),
xytext=(pd.Timestamp('2008-10-06'), -0.2),
arrowprops={"arrowstyle":"->", "color":"gray"})
plt.show()