Pandas

import pandas as pd

# create a dataframe
df = pd.DataFrame({
    'name': ['Alice', 'Bob', 'Charlie'],
    'age': [25, 30, 35],
    'gender': ['F', 'M', 'M'],
    'salary': [50000, 60000, 70000]
})

# select columns
df[['name', 'age']]

# filter rows
df[df['age'] > 30]

# group and aggregate
df.groupby('gender')['salary'].mean()

 

Leave a Comment