plot a pandas dataframe matplotlib
import pandas as pd import matplotlib.pyplot as plt df = pd.Dataframe(Data) df.plot(kind='bar',x="dataframe_1",y="dataframe_2") # bar can be replaced by # scatter or line or even left as default plt.show()
plot a pandas dataframe matplotlib
import pandas as pd import matplotlib.pyplot as plt df = pd.Dataframe(Data) df.plot(kind='bar',x="dataframe_1",y="dataframe_2") # bar can be replaced by # scatter or line or even left as default plt.show()
plot pandas series with matplotlib
import matplotlib.pyplot as plt # maximum range of data available for all three metrics = [2006-2010] sold = home_data.loc[home_data.YearBuilt >= 2006].groupby(by=["YrSold"]).Id.count() built = home_data.loc[home_data.YearBuilt >= 2006].groupby(by=["YearBuilt"]).Id.count() modd = home_data.loc[home_data.YearBuilt >= 2006].groupby(by=["YearRemodAdd"]).Id.count() # extend the data to current year(2021) extend_series = pd.Series([0 for i in range(2011,2022)], index=range(2011,2022)) sold = pd.concat([sold,extend_series]) built = pd.concat([built,extend_series]) modd = pd.concat([built,extend_series]) plt.figure(figsize=(10,16)) plt.subplot(311) plt.xlabel("Year") plt.ylabel("# of Houses Built") plt.plot(built.index, built, color='green') plt.subplot(312) plt.xlabel("Year") plt.ylabel("# of Houses Sold") plt.plot(sold.index, sold, color='red') plt.subplot(313) plt.xlabel("Year") plt.ylabel("# of Houses ReModded") plt.plot(modd.index, modd, color='cyan')
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us