#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jun 27 22:28:03 2023 @author: richardson """ """ fun with Pandas """ import matplotlib.pyplot as plt import pandas as pd import numpy as np ts = pd.Series(np.random.randn(1000), index = pd.date_range(start="6/1/2023",\ end='7/1/2023', periods = 1000)) # 1000 random times according to the normal distribution ts = ts.cumsum() # takes the t-values, and calculates t0, t0+t1, t0+t1+t2,... ts.plot() # better than plt.plot(ts) because it uses the indices ts2 = pd.DataFrame(np.random.randn(1000,5), \ index=ts.index,columns=['S','AM','H','M','L']) ts2 = ts2.cumsum() ts2.plot() ts2.plot(x='AM',y='M') # plots just M vs AM # to plot more than one y value at the same time ts2.plot(x='AM',y=['M','L']) # plots M vs AM in one color # plots L vs AM in the other color df2 = pd.DataFrame(np.random.rand(10, 4), columns=["a", "b", "c", "d"]) #df2.plot.bar() df2.plot.bar(stacked=True) # area plot df2.plot.area()