on
ai 주식투자
- Get link
- X
- Other Apps
Pandas: Powerful Data Analysis in Python
Pandas is a Python library specifically designed for working with structured data – think of data organized in tables, like spreadsheets or SQL databases. It makes data manipulation and analysis much easier and more intuitive.
Key Features & Why it's Useful:
import pandas as pd
# Create a DataFrame from a dictionary
data = {'Name': ['Alice', 'Bob', 'Charlie'],
'Age': [25, 30, 28],
'City': ['New York', 'London', 'Paris']}
df = pd.DataFrame(data)
print(df)
# Output:
# Name Age City
# 0 Alice 25 New York
# 1 Bob 30 London
# 2 Charlie 28 Paris
# Select a column
print(df['Name'])
# Output:
# 0 Alice
# 1 Bob
# 2 Charlie
# Name: Name, dtype: object
# Calculate the average age
average_age = df['Age'].mean()
print(average_age) # Output: 27.666666666666668
Simple Example:
Data Loading, Cleaning, and Basic Analysis with Pandas
Comments
Post a Comment