ssb_timeseries.sample_data
¶
The ssb_timeseries.sample_data
module provides tools for creating sample timeseries data. These are convenience functions for tests and demos.
- create_df(*lists, start_date=None, end_date=None, freq='D', interval=1, separator='_', midpoint=100, variance=10, temporality='AT', decimals=0)¶
Generate sample data for specified date range and permutations over lists.
- Parameters:
start_date (datetime) – The start date of the date range. Optional, default is negative infinity.
end_date (datetime) – The end date of the date range. Optional, default is positive infinity.
*lists (list[str]) – Lists of values to generate combinations from.
freq (str) – The frequency of date generation. ‘Y’ for yearly at last day of year, ‘YS’ for yearly at first day of year, ‘M’ for monthly at last day of month, ‘MS’ for monthly at first day of month, ‘W’ for weekly on Sundays, ‘D’ for daily, ‘H’ for hourly, ‘T’ for minutely, ‘S’ for secondly, etc. Optional, default is ‘D’.
interval (int) – The interval between dates. ; optionalDefault is 1.
separator (str) – The separator used to join combinations. Optional, default is ‘_’.
midpoint (float) – The midpoint value for generating random data. Optional, default is 100.
variance (float) – The variance value for generating random data. Optional, default is 10.
temporality (str) – The temporality of the data. Default is ‘AT’.
decimals (int) – The number of decimal places to round to. Optional, default is 0.
- Returns:
A DataFrame containing sample data.
- Return type:
DataFrame
Example:
` # Generate sample data with no specified start or end date (defaults to +/- infinity) sample_data = generate_sample_df(List1, List2, freq='D') `
- random_numbers(rows, cols, decimals=0, midpoint=100, variance=10)¶
Generate sample dataframe of specified dimensions.
- Return type:
ndarray
- Parameters:
rows (int)
cols (int)
decimals (int)
midpoint (int | float)
variance (int | float)
- series_names(*args, **kwargs)¶
Return all permutations of the elements of multiple groups of strings.
- Parameters:
*args (str | list | tuple | dict) – Each arg in args should be a collection of names to be combined with the other.
**kwargs (str) – One option: ‘separator’ defines a character sequence inserted between name elements. Defaults to ‘_’.
- Returns:
List of names to be used as series names.
- Return type:
list[str]
- Raises:
ValueError – If an argument of an invalid type is passed.