Pandas Concepts

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

External

Internal

Overview

pandas is a Python package that provides fast, flexible, and expressive data structures designed to make working with "relational" or "labeled" data both easy and intuitive. It aims to be the fundamental high-level building block for doing practical, real world data analysis in Python. Pandas is built in top of Numpy. Pandas provides two main data structures DataFrame and Series, which share concepts like axis and index.

Axis

Both DataFrames and Series use the concept of axis. An axis means the direction in a bidimensional data matrix or a vector along which the means are computed. A DataFrame has a row axis and a column axis, while a Series has only one axis. The term comes from numpy, whose ndarray is used to implement the Panda Series. The indexes corresponding to a DataFrame or a Series axes are returned by the axes property.

Index

An index is an immutable sequence used to address data stored in a DataFrame or a Series. By default, it consists in 0-based monotonically increasing integers (RangeIndex), but it can also consists in string labels, or in case of time series, by datetime instances (DatetimeIndex).




A DataFrame Index and a Series Index.

DataFrame

DataFrame

Series

Series

Time Series Processing with Pandas

Time Series Processing with Panda

Index

https://pandas.pydata.org/docs/reference/indexing.html

An index can be thought as individual elements labels, for a Series or as the row labels for a DataFrame.

Generic Index

Index(['distance', 'strength'], dtype='object')

This kind of index is associated with the column axis of a DataFrame.

DataFrame Index

DataFrame Index

Series Index

Series Index

Data Types

String

Datetime

TO PROCESS: https://pandas.pydata.org/docs/reference/api/pandas.Timestamp.html#pandas.Timestamp

Reported as datetime64[ns]. What is this?

Also see

Create a Time Series from CSV

Date format when represented as string: YYYY-MM-DD, "2023-10-01".

Visualization

Both the DataFrame and Series have a plot() method, which delegates to matplotlib.

Datareader

pip3 install pandas_datareader