read_csv is a pandas function that loads delimited text, commonly a CSV file, into a DataFrame. The simplest call supplies only the file path because useful defaults handle headers, column names, and types. section 6.2.1
Load and inspect sales data
import pandas as pd df = pd.read_csv('sales_data.csv') print(type(df)) df.info() The result is a pandas DataFrame whose rows and columns can be analyzed. Inspection reveals row counts, column names, missing values, and pandas dtypes such as object and float64. section 6.2.1
File location matters when an application runs from a different working directory. Build the CSV path from the Python file’s directory with pathlib instead of hardcoding a machine-specific absolute path. section 6.2.2
Listing 6.1 Loading data using data_loader.py
import pandas as pd
from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent
SALES_DATA_PATH = BASE_DIR / "sales_data.csv"
def load_data():
return pd.read_csv(SALES_DATA_PATH)
Use this loader pattern to keep path construction separate from application code and return the DataFrame through a reusable load_data function. section 6.2.2
Useful decisions after loading include:
- Inspect the result with type and info before building dashboard features. section 6.2.1
- Choose a dtype_backend such as pyarrow when the intended pandas representation differs from object and float64. section 6.2.1
- Use DataFrame column selection after loading when the application needs only a subset of fields. section 6.2.1




