Lesson 38 of 55
PythonIntroduction to Pandas
20 minutes
Course progress69%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 38 of 55
Python20 minutes
Keep these ideas in mind as you work through the lesson.
Pandas brings the DataFrame—a powerful, labeled, tabular data structure—into Python. It makes data cleaning, transformation, and analysis straightforward.
import pandas as pd
# Create a DataFrame from a dictionary
df = pd.DataFrame({
'name': ['Alice', 'Bob', 'Charlie'],
'age': [25, 30, 35]
})
print(df)
# Compute the average age
print('Average age:', df['age'].mean())
# Filter rows where age > 28
print('Older than 28:
', df[df['age'] > 28])
Pandas reads CSV, Excel, SQL, and many other formats, and works seamlessly with NumPy, Matplotlib, and scikit‑learn.