This pages gives some examples of creating charts and different graphs using Python.

This is not an exhaustive list, and there are lots of different options available to you.

Most Python libraries/packages for Graphing include Pandas, Mathplotlib, Seaborn, etc. The following examples include the main types of charts/graphs used and will use the graphing features available with the Pandas library.

Data Set: The data set used in the following examples is the San Francisco Bike Share Trips CSV file. After loading the data, the following aggregation was preformed to generate the values for ‘x’, and the main data set was loaded int a variable called ‘df’.

x = df.groupby('start_station_name')['duration'].mean().sort_values().tail(15)

**Line Chart**

x.plot.line()

**Bar Chart**

x.plot.bar()

x.plot.barh()

**Histogram**

# display histogram for all numerical feature distributions df.hist(figsize=(12,10))

# display historgrams for categorical variables # these need to be processed individually categorical = ['start_station_name', 'end_station_name', 'subscription_type'] for i in categorical: df[i].value_counts().plot(kind='bar',figsize = (10, 6),title=i) plt.show()

**Box Plots**

x.plot.box()

**Scatter Plot**

df.plot.scatter(x='end_station_id', y='duration');

**Pie Chart**

x.plot.pie()

There are many other different charting/graphing options available. Additionally there are lots of formatting options improving the layout of the graphs. Although the graphing options available with the Pandas package, there are many other packages that give more appealing displays, for example Seaborn, and many packages that solve particular problems will have their own specific graphing options.