📦 Raw arrays to actionable insights


Welcome back to Pandas Daily! Your daily 5-minute boost to becoming confident in Python.

We created arrays on Day 1. Sliced them on Day 2.

Now comes the real computational power of NumPy. Doing math on entire datasets. No loops. No iteration. Just one line.

Add monthly revenues across regions. Calculate profit margins. Find averages.

All in seconds!!

Let's dive in..

🍃 Add/Subtract like a breeze

In:
import numpy as np
jan_sales = np.array([120, 340, 210])
feb_sales = np.array([150, 290, 180])
print(jan_sales + feb_sales)
print(jan_sales - feb_sales)
Out:
[270 630 390]
[-30 50 30]

🍰 Multiply/Divide like a piece of cake

In:
revenue = np.array([5000, 7500, 6200])
costs = np.array([2000, 3000, 2500])
print(revenue * costs)
print(revenue / costs)
Out:
[10000000 22500000 15500000]
[2.5 2.5 2.48]

⚔️ Arrays & Numbers Crossover

Calculate discount or markup price

In:
prices = np.array([50, 75, 100, 125])
discounted = prices * 0.9
increased = prices + 15
print(discounted)
print(increased)
Out:
[ 45. 67.5 90. 112.5]
[ 65 90 115 140]

✳️ Aggregate however you want

In:
daily_orders = np.array([23, 45, 67, 34, 89, 56, 78])
print(daily_orders.sum())
print(daily_orders.mean())
print(daily_orders.max())
print(daily_orders.min())
Out:
392
56.0
89
23

⏹ Square to calculate area

In:
sides = np.array([3, 5, 7, 9])
areas = sides ** 2
print(areas)
Out: [ 9 25 49 81]

💎 Identify elements that satisfy a condition (premium products)

In:
prices = np.array([45, 78, 120, 95, 200])
print(prices > 100)
Out: [False False True False True]

🌓 Subset data based on given conditions

In: print(prices[prices > 100])
Out: [120 200]

Quick Excel Shortcut 💡

Ctrl + 1 Open the Format Cells dialog box. Quickly change number format, font, borders, or alignment — all from one place.


⭐📣 That's it for today! If you liked it, please share it with anyone who will find it useful and share your feedback below 🐼

Pandas Daily

Beginner to Expert in Python in just 5 minutes

Read more from Pandas Daily

Welcome back to Pandas Daily! Your daily 5-minute boost to becoming confident in Python. You have a spreadsheet with 500 numbers. Your boss asks: "What do you see?" Most will freeze, scroll, guess. Not you! 3 Python functions to turn raw numbers into answers. No calculator, excel sheets. Just code. Statistics isn't boring math. It's how you make decisions with data. Using just the statistics module we find "center" of any dataset. Any data analyst must know the basics‼️ 🎯 Compute simple...

Welcome back to Pandas Daily! Your daily 5-minute boost to becoming confident in Python. Last week we introduced numpy. Created bunch of arrays, sliced them and did some math with them. To prepare data for machine learning or any analysis, we need to learn to control their shape. Today - Reshape flat lists into grids. Flatten 2D tables back to 1D arrays. Create arrays filled with zeros, ones, or random numbers. ⏪ Recap: See dimensions first In: import numpy as np sales = np.array([120, 340,...

Welcome back to Pandas Daily! Your daily 5-minute boost to becoming confident in Python. TGIF! Everyone is talking about AI. Most people take courses. You're going to build it instead. Let's create a simple sentiment analyzer that reads customer reviews and classifies them as positive or negative. No machine learning libraries—just Python. 🎯 Define list of positive and negative words In: positive_words = ["good", "great", "excellent", "amazing", "love", "best"] negative_words = ["bad",...