From c98972ced700b6250915a21af4b76459365743f3 Mon Sep 17 00:00:00 2001 From: Christian Kolset Date: Thu, 24 Apr 2025 23:31:17 -0600 Subject: Updated markdown files to look better after converting to latex files. --- tutorials/module_1/1_excel_to_python.md | 73 +++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 tutorials/module_1/1_excel_to_python.md (limited to 'tutorials/module_1/1_excel_to_python.md') diff --git a/tutorials/module_1/1_excel_to_python.md b/tutorials/module_1/1_excel_to_python.md new file mode 100644 index 0000000..2bf6a0d --- /dev/null +++ b/tutorials/module_1/1_excel_to_python.md @@ -0,0 +1,73 @@ +# Excel to Python + + +- Importing +- Plotting +- Statistical analysis + + + +## **How Excel Translates to Python** + +Here’s how common Excel functionalities map to Python: + +| **Excel Feature** | **Python Equivalent** | +| ----------------------- | -------------------------------------------------------- | +| Formulas (SUM, AVERAGE) | `numpy`, `pandas` (`df.sum()`, `df.mean()`) | +| Sorting & Filtering | `pandas.sort_values()`, `df[df['col'] > value]` | +| Conditional Formatting | `matplotlib` for highlighting | +| Pivot Tables | `pandas.pivot_table()` | +| Charts & Graphs | `matplotlib`, `seaborn`, `plotly` | +| Regression Analysis | `scipy.stats.linregress`, `sklearn.linear_model` | +| Solver/Optimization | `scipy.optimize` | +| VBA Macros | Python scripting with `openpyxl`, `pandas`, or `xlwings` | + +## Statistical functions + +#### SUM +Built-in: +```python +my_array = [1, 2, 3, 4, 5] +total = sum(my_array) +print(total) # Output: 15 +``` +Numpy: +```python +import numpy as np + +my_array = np.array([1, 2, 3, 4, 5]) +total = np.sum(my_array) +print(total) # Output: 15 +``` + +### Average +Built-in: +```python +my_array = [1, 2, 3, 4, 5] +average = sum(my_array) / len(my_array) +print(average) # Output: 3.0 +``` +Numpy: +```python +import numpy as np + +my_array = np.array([1, 2, 3, 4, 5]) +average = np.mean(my_array) +print(average) # Output: 3.0 +``` + + + +## Plotting +We can use the package *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. +```python +import matplotlib.pyplot as plt + +fig, ax = plt.subplots() # Create a figure containing a single Axes. +ax.plot([1, 2, 3, 4], [1, 4, 2, 3]) # Plot some data on the Axes. +plt.show() # Show the figure. +``` + +Check out the documentation pages for a [simple example](https://matplotlib.org/stable/users/explain/quick_start.html#a-simple-example) or more information on the types of plots you came create [here](https://matplotlib.org/stable/plot_types/index.html). \ No newline at end of file -- cgit v1.2.3