...
Code Block |
---|
import pandas as pd header = pd.MultiIndex.from_product([['Semester1','Semester2'],['Maths','Science']]) d=([[12,45,67,56],[78,89,45,67],[45,67,89,90],[67,44,56,55]]) df = pd.DataFrame(d, index=['Alisa','Bobby','Cathrine','Jack'], columns=header) # stack the dataframe stacked_df=df.stack() # unstack the dataframe unstacked_df = stacked_df.unstack() # stack the dataframe of column at level 0 stacked_df_lvl=df.stack(level=0) # unstack the dataframe unstacked_df1 = stacked_df_lvl.unstack() |
MatPlotLib
Line chart by city and population by MatPlotLib
Code Block |
---|
from matplotlib import pyplot as plt
plt.plot(["Seoul","Paris","Seattle"], [30,25,55])
plt.xlabel('City')
plt.ylabel('Response')
plt.title('Experiment Result')
plt.show() |
Result
Bar chart by city and population by MatPlotLib
Code Block |
---|
from matplotlib import pyplot as plt
plt.bar(["Seoul","Paris","Seattle"], [30,25,55])
plt.xlabel('City')
plt.ylabel('Response')
plt.title('Experiment Result')
plt.show() |
Result
Spot graph by age and score by MapPlotLib
...