{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Excel to Python\n", "\n", "- Importing\n", "- Plotting\n", "- Statistical analysis\n", "\n", "## **How Excel Translates to Python**\n", "\n", "Here’s how common Excel functionalities map to Python:\n", "\n", "| **Excel Feature** | **Python Equivalent** |\n", "|----------------------|--------------------------------------------------|\n", "| Formulas (SUM, AVERAGE) | `numpy`, `pandas` (`df.sum()`, `df.mean()`) |\n", "| Sorting & Filtering | `pandas.sort_values()`, `df[df['col'] > value]` |\n", "| Conditional Formatting | `matplotlib` for highlighting |\n", "| Pivot Tables | `pandas.pivot_table()` |\n", "| Charts & Graphs | `matplotlib`, `seaborn`, `plotly` |\n", "| Regression Analysis | `scipy.stats.linregress`, `sklearn.linear_model` |\n", "| Solver/Optimization | `scipy.optimize` |\n", "| VBA Macros | Python scripting with `openpyxl`, `pandas`, or `xlwings` |\n", "\n", "## Statistical functions\n", "\n", "#### SUM\n", "\n", "Built-in:\n", "\n", "``` python\n", "my_array = [1, 2, 3, 4, 5]\n", "total = sum(my_array)\n", "print(total) # Output: 15\n", "```\n", "\n", "Numpy:\n", "\n", "``` python\n", "import numpy as np\n", "\n", "my_array = np.array([1, 2, 3, 4, 5])\n", "total = np.sum(my_array)\n", "print(total) # Output: 15\n", "```\n", "\n", "### Average\n", "\n", "Built-in:\n", "\n", "``` python\n", "my_array = [1, 2, 3, 4, 5]\n", "average = sum(my_array) / len(my_array)\n", "print(average) # Output: 3.0\n", "```\n", "\n", "Numpy:\n", "\n", "``` python\n", "import numpy as np\n", "\n", "my_array = np.array([1, 2, 3, 4, 5])\n", "average = np.mean(my_array)\n", "print(average) # Output: 3.0\n", "```\n", "\n", "## Plotting\n", "\n", "We can use the package *matplotlib* to plot our graphs in python.\n", "Matplotlib provides data visualization tools for the Scientific Python\n", "Ecosystem. You can make very professional looking figures with this\n", "tool.\n", "\n", "Here is a section from the matplotlib documentation page that you can\n", "run in python.\n", "\n", "``` python\n", "import matplotlib.pyplot as plt\n", "\n", "fig, ax = plt.subplots() # Create a figure containing a single Axes.\n", "ax.plot([1, 2, 3, 4], [1, 4, 2, 3]) # Plot some data on the Axes.\n", "plt.show() # Show the figure.\n", "```\n", "\n", "Check out the documentation pages for a [simple\n", "example](https://matplotlib.org/stable/users/explain/quick_start.html#a-simple-example)\n", "or more information on the types of plots you came create\n", "[here](https://matplotlib.org/stable/plot_types/index.html)." ], "id": "3e04cd8a-c731-494a-bf4f-dfe745a8a487" } ], "nbformat": 4, "nbformat_minor": 5, "metadata": {} }