<jupyter_start><jupyter_text>Libraries---The standard Python library is robust and rich in features. IMHO one of the key reasons Python is so successful is the extensibility through a broad range of community driven, open source 3rd party libraries - Pandas (built on NumPy), MatplotLib, Jupyter, SciKitLearn, FbProphet to name a few.From command line run the following:        pip install pandas    ...or if you installed with Anaconda Distribution        conda install pandas    The libraries demo'd here are just the tip of the iceberg!!<jupyter_code># import the os library for file manipulation
import os
# import the pandas library and alias it
import pandas as pd
# we've already seen how to import a subset of features from a library using "from"
from numpy import array
# create a data frame from a sample csv
df = pd.read_csv("SalesOrderHeader.csv", delimiter="\t")
# top of the data frame
df.head()
# actually, I want more
df.head(10)
# and the end
df.tail()
# Summarise the DataFrame
df.describe()
# Show a single column from the data frame, use .head() to show the top again
df["SalesOrderID"].head()
# Get the data from a single row (in this case, the 3rd row)
df.iloc[2]
# Get the SalesOrderID from a single row
df.iloc[2]["SalesOrderID"]
df.iloc[2][0]<jupyter_output><empty_output><jupyter_text>--- Plotting librariesFor Data Analytics, Python makes it easy to visualise data using plotting libraries like:* MatplotLib* SeaBorn* Bokeh* HoloViews* ggplot* Plotly<jupyter_code># MatplotLib is one of the most commonly used libraries for dataviz
# import the MatPlotLib plotting library and assign an alias
import matplotlib.pyplot as plt
# Plot a simple chart
plt.plot(df["SalesOrderID"], df["TotalDue"])
plt.ylabel('TotalDue')
plt.xlabel('Sales Order ID')
plt.show()
# the plot() method tries to guess the best chart for the job...
plt.plot(df["TerritoryID"], df["TotalDue"])
plt.ylabel('TotalDue')
plt.xlabel('Territory ID')
plt.show()
#Use a groupby to process the TerritoryID
groupedDF = df.groupby("TerritoryID").sum()
groupedDF.head()
# there are more explicit methods for specifying a graph type e.g. bar
plt.bar(groupedDF.index, groupedDF["TotalDue"])
# compare to 
# plt.bar(groupedDF.index, groupedDF["TotalDue"])
plt.ylabel("Total Due")
plt.xlabel("Territory ID")
plt.title("Total Due by Territory")
plt.show()<jupyter_output><empty_output><jupyter_text>--- Plotting Math functions with NumPyNumpy is one of the most commonly used libraries for processing numerical information, mathematics and statistical functions. It is also a key component in Pandas.<jupyter_code>#import matplotlib.pyplot as plt #........reimport not necessary
#import matplotlib as mpl
import numpy as np

x = np.linspace(0, 20, 100)
plt.plot(x, np.sin(x))
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09763948497854077, 'fraction_numerical': 0.005007153075822604, 'mean_word_length': 5.1607929515418505, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '368552', 'license': 'MIT', 'n_tokens_mistral': 893, 'n_tokens_neox': 836, 'n_words': 345, 'path': 'Python Intro/notebooks/4. Libraries.ipynb', 'repo_name': 'SimonStride/Presentations', 'size': '2796'}