1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# Excel to Python
^d7d771
- 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).
|