Loading Data

Loading Data: Loading a CSV File, Loading an Excel Workbook, Loading JSON, Flat and Nested.

Updated

  1. Loading a CSV File (Apprentice): pd.read_csv loads a CSV file into a DataFrame, usecols and nrows load only the columns and rows you need, sep reads a file whose values are split by semicolons, and a FileNotFoundError means the path doesn't lead from the folder the notebook runs in to the file.
  2. Loading an Excel Workbook (Apprentice): pd.read_excel loads a sheet of an Excel workbook into a DataFrame with openpyxl doing the reading, sheet_name picks the sheet by its name, skiprows steps over title rows above the table, and sheet_name=None loads every sheet at once as a dictionary of DataFrames.
  3. Loading JSON, Flat and Nested (Apprentice): pd.read_json loads a JSON list of records into a DataFrame, lines=True reads JSON Lines with one record on each line, and pd.json_normalize with record_path and meta turns a nested list, such as each vendor's reviews, into one row for each item.