DEV Community

Blackmare01wolf
Blackmare01wolf

Posted on

Getting Started with Pandas: The Power Tool for Data Analysis in Python

Introduction

If you work with data, pandas is your best friend. It lets you manipulate, analyze, and visualize data with just a few lines of code.

Installation

pip install pandas
Enter fullscreen mode Exit fullscreen mode

Basic Objects

  • Series – 1D array with labels
  • DataFrame – 2D table with rows & columns

Creating DataFrames

import pandas as pd

data = {
    'Name': ['AF4', 'Shadow', 'Wolf'],
    'Score': [90, 85, 95]
}

df = pd.DataFrame(data)
print(df)

Enter fullscreen mode Exit fullscreen mode

Reading & Writing Files

df = pd.read_csv('file.csv')
df.to_csv('output.csv', index=False)
Enter fullscreen mode Exit fullscreen mode

DataFrame Operations

print(df.describe())  # Stats summary
print(df.head())      # First few rows

df['Score'] = df['Score'] + 5
Enter fullscreen mode Exit fullscreen mode

Filtering & Selection

high_scores = df[df['Score'] > 90]
print(high_scores)

Enter fullscreen mode Exit fullscreen mode

Grouping and Aggregation

df.groupby('Name').mean()
Enter fullscreen mode Exit fullscreen mode

Conclusion

pandas is the heart of Python data analysis. Once you get comfortable, you'll fly through any dataset like a pro.

Top comments (0)