ADVERTISEMENT
Google AdSense Slot (headerLeaderboard)

Set your Publisher ID in src/config/ads.ts to display live ads.

Pandas Tutorial• 6 min read

Pandas Introduction: Series & DataFrame Architecture

1D labeled Series vs 2D tabular DataFrames with explicit row and column indexes

Pandas is the premier Python library for data manipulation and analysis, built directly on top of NumPy to provide fast, labeled tabular data structures.

Series vs DataFrame

Series: A 1D labeled array capable of holding any data type. It consists of an array of data paired with an explicit index array.

DataFrame: A 2D labeled tabular data structure with columns of potentially different types, resembling an Excel spreadsheet or SQL table.

Every column in a DataFrame is internally stored as a Pandas Series sharing a common index.

Creating DataFrames from Dictionaries
import pandas as pd

# Create DataFrame from dictionary of lists
data = {
    "product": ["MacBook Pro", "Dell XPS", "ThinkPad X1"],
    "price": [1999.00, 1499.50, 1650.00],
    "in_stock": [True, True, False]
}

df = pd.DataFrame(data, index=["sku_101", "sku_102", "sku_103"])
print("Tabular DataFrame:
", df)
print("
DataFrame Info:")
print(f"Shape: {df.shape}, Columns: {list(df.columns)}")
DataFrames feature named columns and custom index labels.
Pro Tip

Use df.info() and df.describe() as the very first commands whenever loading any new dataset into Pandas.

ADVERTISEMENT
Google AdSense Slot (inContentBanner)

Set your Publisher ID in src/config/ads.ts to display live ads.

Test Yourself With Exercise

+15 XP

What is the relationship between a Pandas DataFrame and a Pandas Series?