Categories

Are you new to Python and trying to make a beautiful graph? I’ve reviewed four of the most popular and picked the best option for beginners. For the cells below, I used Jupyer Notebook with these modules that can be installed via pip (pandas, numpy, plotly, cufflinks, seaborn, chartify).

In a normal day, I’ll open my Jupyter Notebook, import a CSV that I created using SQL/Hive.

remember, this doesn't go in jupyter notebook, it goes in your terminal (the thing with a black screen, sort of looks like that thing from The Matrix)
pip install plotly
pip install cufflinks
pip install chartify
pip install seaborn

import pandas as pd
import numpy as np
%matplotlib inline
import pandas as pd
%cd -q Downloads
#%cd this changes my directory to the Downloads folder
df1=pd.read_csv('blog_example.csv')
#this uses pandas (pd) to read the csv in the Downloads folder
#this example data mimics Google Ad Manager data, but for this exercise, it's full of random numbers
df2=df1.pivot_table(values='imps',index='day',columns='subset',aggfunc='sum')
#I now have two dataframes: df1, df2. This will be used later, depending on the graph
df2.head()
#.head() will show the first five rows of df2

Chartify

import chartify
df=df1.groupby(['day','subset'],as_index=False).sum()
#chartify can handle a flat table, no need to pivot it
%cd -q
#%cd was needed to change the active directory to 'python', earlier in this lesson I moved it to the Downloads folder.
ch = chartify.Chart(blank_labels=True, x_axis_type='datetime')
ch.plot.line(
data_frame=df,
x_column='day'
,y_column='imps'
,color_column='subset'
)
ch.show()