Intro to Pandas and NumPy for Teens

Hey there! 🌟 Ready to dive into the world of data with some cool tools? Imagine you're organizing a huge beach party on St. Kitts and Nevis. You’ve got to keep track of everything – from the number of coconuts to how many friends are coming. Sounds like a lot, right? Well, that's where Pandas and NumPy come in!

Pandas 🐼

Think of Pandas like your ultimate party planner. It helps you organize all your data in neat tables, kind of like how you’d write down a list of who’s bringing what to the party. With Pandas, you can easily see everything at a glance, from who’s bringing the drinks to who’s in charge of the music playlist.

Example:

import pandas as pd

# Create a list of friends and what they are bringing to the party
data = {
    'Friend': ['Aaliyah', 'Jaden', 'Kai', 'Liam'],
    'Item': ['Drinks', 'Snacks', 'Music', 'Coconuts']
}

# Convert the list into a DataFrame
party_planner = pd.DataFrame(data)

# Display the DataFrame
print(party_planner)

NumPy 🔢

Now, imagine you want to do some quick math – like figuring out how many more coconuts you need if each friend drinks two. NumPy is your calculator for that! It’s super fast and can handle all sorts of numbers, just like calculating how many waves hit the beach in an hour.

Example:

import numpy as np

# Number of friends coming to the party
friends = np.array([4])

# Each friend drinks 2 coconuts
coconuts_per_friend = 2

# Calculate total coconuts needed
total_coconuts = friends * coconuts_per_friend

print(f'Total coconuts needed: {total_coconuts}')

Both Pandas and NumPy are like your secret weapons to make sure your party (or any project) is a hit! 🎉 Ready to give them a try?