Python Data Types Reference Guide

Built-in Data Types

Numeric Types

  • int: Integer numbers, e.g., 42
  • float: Floating-point numbers, e.g., 3.14
  • complex: Complex numbers, e.g., 2 + 3j

Sequence Types

  • list: Mutable ordered sequences, e.g., [1, 2, 3]
  • tuple: Immutable ordered sequences, e.g., (1, 2, 3)
  • str: Immutable sequences of Unicode characters, e.g., 'hello'

Mapping Types

  • dict: Mutable unordered collections of key-value pairs, e.g., {'a': 1, 'b': 2}

Polars Objects

See the Polars User Guide Here. Specific Data Structure Documentation Here.

  • DataFrame: Tabular data structure with labeled axes (rows and columns)
    • Built on top of Apache Arrow
    • Efficient handling of large datasets
    • Easy integration with Pandas and NumPy
    • Example:
import polars as pl

# Create a DataFrame
df = pl.DataFrame({
    'A': [1, 2, 3],
    'B': [4, 5, 6]
})
  • Series: One-dimensional labeled array capable of holding any data type
    • Similar to a single column of a DataFrame
    • Efficient computation and transformation operations
    • Example:
import polars as pl

# Create a Series
s = pl.Series([1, 2, 3, 4, 5])

xarray Objects

See the xarray User Guide Here. Specific Data Structure Documentation Here

  • DataArray: Multi-dimensional labeled array
    • Data structure for storing n-dimensional data arrays
    • Supports labeled dimensions, coordinates, and attributes
    • Example:
import xarray as xr

# Create a DataArray
da = xr.DataArray(
    data=[[1, 2], [3, 4]],
    dims=("x", "y"),
    coords={"x": [10, 20], "y": ["a", "b"]}
)
  • Dataset: Multi-dimensional array with labeled data variables and dimensions
    • Container for multiple DataArrays sharing the same dimensions
    • Useful for storing and manipulating multiple related variables
    • Example:
import xarray as xr

# Create a Dataset
ds = xr.Dataset({
    'temperature': ([('x', 'y'), [[1, 2], [3, 4]]]),
    'precipitation': ([('x', 'y'), [[0.1, 0.2], [0.3, 0.4]]])
})