how to plot multiple time series of a dataframe in python

To plot multiple time series of a dataframe in Python, you can use the matplotlib library and the plot method of pandas dataframes. Assuming that you have a dataframe df with a datetime index and multiple columns, here's the code:

main.py
import matplotlib.pyplot as plt
import pandas as pd

# assume df is a pandas dataframe with datetime index and multiple columns
df.plot(figsize=(10,5)) # adjust figsize as needed
plt.xlabel('Date')
plt.ylabel('Value')
plt.title('Multiple Time Series')
plt.show()
263 chars
10 lines

This will plot all the columns in df over time. You can also customize the axes labels, title, and figure size as needed.

related categories

gistlibby LogSnag