Loading content...
Loading content...
Master the foundational building blocks of Data Analytics in Python: 1-dimensional labeled Series and 2-dimensional tabular DataFrames. Understand rows as records, columns as variables, and essential dataset inspection tools.
Real-world data analytics rarely deals with abstract math formulas. Instead, analysts work with structured, tabular business datasets with column names, row identifiers, and mixed data types (names, ages, revenues, dates):
| # | Name (text) | Age (integer) | Sales (currency) |
|---|---|---|---|
| 0 | Amit | 22 | $50,000 |
| 1 | Priya | 24 | $70,000 |
| 2 | Rahul | 21 | $45,000 |
Specialized in homogeneous, unlabeled numerical arrays, high-speed C-loops, matrix algebra, and vectorized arithmetic.
Built directly on top of NumPy to provide labeled rows, named columns, mixed data types, CSV/Excel file loading, and intuitive table manipulation.
A Series is a one-dimensional labeled array capable of holding any data type (integers, strings, floating point numbers, Python objects). It consists of two parallel components: the Values and the Index (labels).
Notice the left column: 0, 1, 2, 3. That is the Index. Unlike Python lists where indices are strictly numbers, a Pandas Series allows you to define custom, meaningful labels:
Create a Series containing: 45000, 32000, 78000, 25000, 60000. Display it, access a value, and create a labeled version with month names:
A DataFrame is a 2-dimensional labeled data structure with columns of potentially different types. You can think of it like a spreadsheet or SQL table. The most common way beginners create a DataFrame in Python is from a dictionary of lists:
Each horizontal row represents an individual observation or business record (e.g. one specific employee).
Each vertical column represents a specific attribute, feature, or measurement (e.g. Name, Age, Sales).
The index labels each row uniquely (by default 0, 1, 2...), enabling precise referencing.
Mastering this structural distinction is the single most important mental model in Pandas:
Sales numbersCreate a DataFrame from a Python dictionary containing Name, Age, and Sales, then print the result:
When analyzing a table, you constantly select specific columns. Pandas provides two fundamental selection behaviors based on bracket syntax:
df["Sales"]Extracts a single column. The result collapses to a 1D Series object.
df[["Name", "Sales"]]Passes a list of column names. The result preserves 2D shape and returns a new DataFrame.
Whenever a Data Analyst loads a new dataset, their very first instinct is:"Understand what the data looks like."NumPy provides 6 critical beginner inspection attributes and methods:
(rows, columns) indicating dataset volume.int64, object) of every column.Given inventory data for an electronics retailer. Write the inspection commands to inspect shape, column names, data types, and preview the first rows:
When a professional Data Analyst looks at a Pandas DataFrame, here is how they conceptualize it:
The complete business dataset or transaction ledger.
A single metric or variable (e.g. df["Revenue"]).
A single transaction, customer record, or timestamped event.
Selected subset for analysis (e.g. df[["Product", "Revenue"]]).
Given an employee compensation table. Complete all 6 tasks to inspect and subset the dataset:
Salary column as a 1D SeriesEmployee and Salary together as a 2D DataFrameKeep these 4 frequent beginner traps in mind when writing Pandas code:
import pandas as pdUsing pd.DataFrame() without importing pandas raises NameError: name 'pd' is not defined. Always import first!
df["Sales"] yields a 1D Series. If you need a DataFrame sub-table (e.g. for styling or merging), use double brackets df[["Sales"]].
Unlike NumPy arrays which are strictly homogeneous, a DataFrame can hold text (object), numbers (int64), and decimals (float64) across different columns!
df["Name"] selects a column by name. Passing an integer like df[0] does not select row 0; row indexing uses .iloc or .loc.
Test your understanding of Series, DataFrames, column slicing, and dataset inspection:
Test your understanding with real-world query prediction and syntax questions.
What is the fundamental architectural relationship between a Pandas Series and a Pandas DataFrame?