pandas Tables
pandas Tables: DataFrames: Rows, Columns and the Index, Loading a CSV File, A First Look: head, info and describe, Counting What's There: value_counts and…
Updated
- DataFrames: Rows, Columns and the Index (Apprentice): A DataFrame is pandas' table, and shape, columns and dtypes describe it, df['col'] picks one column as a Series, df[['a', 'b']] picks several as a smaller table, a new column can be made from two others in one line, and the index labels every row.
- 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.
- A First Look: head, info and describe (Apprentice): head, tail and sample show a few of a DataFrame's rows, info lists every column's type and how many values are there (the first hint of missing values), and describe sums up each number column in eight numbers, from count and mean to the quartiles, with include='all' adding the text columns.
- Counting What's There: value_counts and unique (Apprentice): value_counts counts how many rows hold each value of a column, most common first, normalize=True turns the counts into shares of the whole, unique lists the different values in a column and nunique counts them.