Index

SQLite

SQL: Index Types and When to Use Them

Indexes are data structures that allow your database to find rows without scanning entire tables. Think of them like a book’s index—instead of reading every page to find mentions of ‘B-tree,’ you…

Read more →
SQL

SQL - CREATE INDEX and DROP INDEX

Indexes function as lookup tables that map column values to physical row locations. Without an index, the database performs a full table scan, examining every row sequentially. With a proper index,…

Read more →
Python

PySpark - Select Columns by Index

PySpark DataFrames are designed around named column access, but there are legitimate scenarios where selecting columns by their positional index becomes necessary. You might be processing CSV files…

Read more →
Pandas

Pandas - Set/Reset Column as Index

• Setting a column as an index transforms it from regular data into row labels, enabling faster lookups and more intuitive data alignment—use set_index() for single or multi-level indexes without…

Read more →
Pandas

Pandas - Reset Index of DataFrame

• The reset_index() method converts index labels into regular columns and creates a new default integer index, essential when you need to flatten hierarchical indexes or restore a clean numeric…

Read more →
Pandas

Pandas - Rename Column by Index

When working with DataFrames from external sources, you’ll frequently encounter datasets with auto-generated column names, duplicate headers, or names that don’t follow Python naming conventions….

Read more →
Pandas

Pandas - Join on Index

Pandas provides the join() method specifically optimized for index-based operations. Unlike merge(), which defaults to column-based joins, join() leverages the DataFrame index structure for…

Read more →
Pandas

Pandas - Drop Rows by Index

• Pandas offers multiple methods to drop rows by index including drop(), boolean indexing, and iloc[], each suited for different scenarios from simple deletions to complex conditional filtering

Read more →
Pandas

How to Sort by Index in Pandas

Pandas DataFrames maintain an index that serves as the row identifier, but this index doesn’t always stay in the order you expect. After merging datasets, filtering rows, or creating custom indices,…

Read more →
Pandas

How to Set Index in Pandas

Every pandas DataFrame has an index, whether you set one explicitly or accept the default integer sequence. The index isn’t just a row label—it’s the backbone of pandas’ data alignment system. When…

Read more →
Pandas

How to Reset Index in Pandas

Understanding how to manipulate DataFrame indexes is fundamental to working effectively with pandas. The index isn’t just a row label—it’s a powerful tool for data alignment, fast lookups, and…

Read more →
Pandas

How to Merge on Index in Pandas

Most pandas tutorials focus on merging DataFrames using columns, but index-based merging is often the cleaner, faster approach—especially when your data naturally has meaningful identifiers like…

Read more →
Python

How to Index Arrays in NumPy

NumPy array indexing goes far beyond what Python lists offer. While Python lists give you basic slicing, NumPy provides a rich vocabulary for selecting, filtering, and reshaping data with minimal…

Read more →