\section{Excel to Python}\label{excel-to-python}

\begin{itemize}
\tightlist
\item
  Importing
\item
  Plotting
\item
  Statistical analysis
\end{itemize}

\subsection{\texorpdfstring{\textbf{How Excel Translates to
Python}}{How Excel Translates to Python}}\label{how-excel-translates-to-python}

Here's how common Excel functionalities map to Python:

\begin{longtable}[]{@{}
  >{\raggedright\arraybackslash}p{(\columnwidth - 2\tabcolsep) * \real{0.2911}}
  >{\raggedright\arraybackslash}p{(\columnwidth - 2\tabcolsep) * \real{0.7089}}@{}}
\toprule\noalign{}
\begin{minipage}[b]{\linewidth}\raggedright
\textbf{Excel Feature}
\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedright
\textbf{Python Equivalent}
\end{minipage} \\
\midrule\noalign{}
\endhead
\bottomrule\noalign{}
\endlastfoot
Formulas (SUM, AVERAGE) & \texttt{numpy}, \texttt{pandas}
(\texttt{df.sum()}, \texttt{df.mean()}) \\
Sorting \& Filtering & \texttt{pandas.sort\_values()},
\texttt{df{[}df{[}\textquotesingle{}col\textquotesingle{}{]}\ \textgreater{}\ value{]}} \\
Conditional Formatting & \texttt{matplotlib} for highlighting \\
Pivot Tables & \texttt{pandas.pivot\_table()} \\
Charts \& Graphs & \texttt{matplotlib}, \texttt{seaborn},
\texttt{plotly} \\
Regression Analysis & \texttt{scipy.stats.linregress},
\texttt{sklearn.linear\_model} \\
Solver/Optimization & \texttt{scipy.optimize} \\
VBA Macros & Python scripting with \texttt{openpyxl}, \texttt{pandas},
or \texttt{xlwings} \\
\end{longtable}

\subsection{Statistical functions}\label{statistical-functions}

\paragraph{SUM}\label{sum}

Built-in:

\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{my\_array }\OperatorTok{=}\NormalTok{ [}\DecValTok{1}\NormalTok{, }\DecValTok{2}\NormalTok{, }\DecValTok{3}\NormalTok{, }\DecValTok{4}\NormalTok{, }\DecValTok{5}\NormalTok{]}
\NormalTok{total }\OperatorTok{=} \BuiltInTok{sum}\NormalTok{(my\_array)}
\BuiltInTok{print}\NormalTok{(total)  }\CommentTok{\# Output: 15}
\end{Highlighting}
\end{Shaded}

Numpy:

\begin{Shaded}
\begin{Highlighting}[]
\ImportTok{import}\NormalTok{ numpy }\ImportTok{as}\NormalTok{ np}

\NormalTok{my\_array }\OperatorTok{=}\NormalTok{ np.array([}\DecValTok{1}\NormalTok{, }\DecValTok{2}\NormalTok{, }\DecValTok{3}\NormalTok{, }\DecValTok{4}\NormalTok{, }\DecValTok{5}\NormalTok{])}
\NormalTok{total }\OperatorTok{=}\NormalTok{ np.}\BuiltInTok{sum}\NormalTok{(my\_array)}
\BuiltInTok{print}\NormalTok{(total)  }\CommentTok{\# Output: 15}
\end{Highlighting}
\end{Shaded}

\subsubsection{Average}\label{average}

Built-in:

\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{my\_array }\OperatorTok{=}\NormalTok{ [}\DecValTok{1}\NormalTok{, }\DecValTok{2}\NormalTok{, }\DecValTok{3}\NormalTok{, }\DecValTok{4}\NormalTok{, }\DecValTok{5}\NormalTok{]}
\NormalTok{average }\OperatorTok{=} \BuiltInTok{sum}\NormalTok{(my\_array) }\OperatorTok{/} \BuiltInTok{len}\NormalTok{(my\_array)}
\BuiltInTok{print}\NormalTok{(average)  }\CommentTok{\# Output: 3.0}
\end{Highlighting}
\end{Shaded}

Numpy:

\begin{Shaded}
\begin{Highlighting}[]
\ImportTok{import}\NormalTok{ numpy }\ImportTok{as}\NormalTok{ np}

\NormalTok{my\_array }\OperatorTok{=}\NormalTok{ np.array([}\DecValTok{1}\NormalTok{, }\DecValTok{2}\NormalTok{, }\DecValTok{3}\NormalTok{, }\DecValTok{4}\NormalTok{, }\DecValTok{5}\NormalTok{])}
\NormalTok{average }\OperatorTok{=}\NormalTok{ np.mean(my\_array)}
\BuiltInTok{print}\NormalTok{(average)  }\CommentTok{\# Output: 3.0}
\end{Highlighting}
\end{Shaded}

\subsection{Plotting}\label{plotting}

We can use the package \emph{matplotlib} to plot our graphs in python.
Matplotlib provides data visualization tools for the Scientific Python
Ecosystem. You can make very professional looking figures with this
tool.

Here is a section from the matplotlib documentation page that you can
run in python.

\begin{Shaded}
\begin{Highlighting}[]
\ImportTok{import}\NormalTok{ matplotlib.pyplot }\ImportTok{as}\NormalTok{ plt}

\NormalTok{fig, ax }\OperatorTok{=}\NormalTok{ plt.subplots()             }\CommentTok{\# Create a figure containing a single Axes.}
\NormalTok{ax.plot([}\DecValTok{1}\NormalTok{, }\DecValTok{2}\NormalTok{, }\DecValTok{3}\NormalTok{, }\DecValTok{4}\NormalTok{], [}\DecValTok{1}\NormalTok{, }\DecValTok{4}\NormalTok{, }\DecValTok{2}\NormalTok{, }\DecValTok{3}\NormalTok{])  }\CommentTok{\# Plot some data on the Axes.}
\NormalTok{plt.show()                           }\CommentTok{\# Show the figure.}
\end{Highlighting}
\end{Shaded}

Check out the documentation pages for a
\href{https://matplotlib.org/stable/users/explain/quick_start.html\#a-simple-example}{simple
example} or more information on the types of plots you came create
\href{https://matplotlib.org/stable/plot_types/index.html}{here}.
