toy_cities#

skrub.datasets.toy_cities(seed=0, size=1000, nulls=0.1, n_metrics=4)[source]#

Generate a synthetic dataframe example with a variety of column types.

This can be used to showcase dataframes containing strings, dates and floats, columns containing null values, and strongly correlated columns.

Contains the following columns: uid: A random identifying string of characters. cities: A city randomly picked in a list of 20, or a null value. encoded_cities: Ordinal encoding applied to the previous column. start: A datetime. end: A datetime later than the previous, or a null value. metric_1, metric_2, etc: Randomly chosen float values.

Parameters:
seedint, default=0

Seed for random generation.

sizeint, default=1000

Number of rows in the output.

nullsfloat in [0, 1], default=0.1

Probability of a cell in ‘cities’ or ‘end’ being null.

n_metricsint, default=4

Number of ‘metrics’ columns added.

Returns:
pandas dataframe

The randomly-generated dataframe, with size rows and 5 + n_metrics columns.

Examples

>>> from skrub.datasets import toy_cities
>>> df = toy_cities(seed=5, size=3, n_metrics=2)
>>> df
          uid     cities  ...  metric_0  metric_1
0  IPbQyAGoYc  Stockholm  ...  0.227319  0.895448
1  otDvgcachZ     Vienna  ...  0.872195  0.018517
2  jHNmownYjU        NaN  ...  0.707496  0.001200