Utilities functions
Polars
filter_tranges_df
filter_tranges_df (df:polars.dataframe.frame.DataFrame, tranges:Tuple[list,list], time_col:str='time')
- Filter data by time ranges
filter_tranges
filter_tranges (time:polars.series.series.Series, tranges:Tuple[list,list])
- Filter data by time ranges, return the indices of the time that are in the time ranges (left inclusive, right exclusive)
DataFrame.plot
DataFrame.plot (*args, **kwargs)
Partition the dataset by time
partition_data_by_time
partition_data_by_time (df:polars.lazyframe.frame.LazyFrame|polars.dataf rame.frame.DataFrame, method)
*Partition the dataset by time
Args: df: Input DataFrame. method: The method to partition the data.
Returns: Partitioned DataFrame.*
partition_data_by_year_month
partition_data_by_year_month (df:polars.dataframe.frame.DataFrame)
*Partition the dataset by year
Args: df: Input DataFrame.
Returns: Partitioned DataFrame.*
partition_data_by_year
partition_data_by_year (df:polars.dataframe.frame.DataFrame)
*Partition the dataset by year
Args: df: Input DataFrame.
Returns: Partitioned DataFrame.*
partition_data_by_ts
partition_data_by_ts (df:polars.dataframe.frame.DataFrame, ts:datetime.timedelta)
*Partition the dataset by time
Args: df: Input DataFrame. ts: Time interval.
Returns: Partitioned DataFrame.*
concat_partitions
concat_partitions (partitioned_input:Dict[str,Callable])
*Concatenate input partitions into one DataFrame.
Args: partitioned_input: A dictionary with partition ids as keys and load functions as values.*
concat_df
concat_df (dfs:list[typing.Union[polars.dataframe.frame.DataFrame,polars. lazyframe.frame.LazyFrame,pandas.core.frame.DataFrame]])
Concatenate a list of DataFrames into one DataFrame.
Resample data
format_timedelta
format_timedelta (time)
Format timedelta to timedelta
resample
resample (df:polars.lazyframe.frame.LazyFrame|polars.dataframe.frame.Dat aFrame, every:datetime.timedelta, period:datetime.timedelta=None, offset:datetime.timedelta=None, shift:datetime.timedelta=None, time_column='time')
Resample the DataFrame
resample
resample (df:polars.lazyframe.frame.LazyFrame|polars.dataframe.frame.Dat aFrame, every:datetime.timedelta, period:datetime.timedelta=None, offset:datetime.timedelta=None, shift:datetime.timedelta=None, time_column='time')
Resample the DataFrame
resample
resample (df:polars.lazyframe.frame.LazyFrame|polars.dataframe.frame.Dat aFrame, every:datetime.timedelta, period:datetime.timedelta=None, offset:datetime.timedelta=None, shift:datetime.timedelta=None, time_column='time')
Resample the DataFrame
calc_vec_mag
calc_vec_mag (vec)
check_fgm
check_fgm (vec:xarray.core.dataarray.DataArray)