energy_analysis_toolbox.pandas#
Add an accessor to pandas.DataFrame and pandas.Series for the computation toolbox.
In order for the accessors to be accessible, this module must be imported.
The module is not imported by default when importing energy_analysis_toolbox:
import energy_analysis_toolbox as et
import energy_analysis_toolbox.pandas
Series#
A pandas series convey only one steam of data. It can be a timeseries of power, energy, temperature, etc.
Hence, the functionalities of the computation toolbox are limited to the following assumptions:
The index is a datetime index
The values are numeric
There is no missing values, i.e. the index is complete, and the value correspond to the interval between the index and the next index.
If not provided as an argument, the last timestep duration is assumed to be the same as the previous one.
Knowing this, if the accessor has been enabled, it becomes available on any pandas.Series with name eat. Operations such as the following becom possible:
my_series.eat.to_freq('1h', method='volume_conservative')
a_power_series.eat.to_energy()
More examples in Accessing the energy_analysis_toolbox from the Pandas API.
Examples of use#
If the accessor has been enabled, it becomes available on any pandas.DataFrame with name eat. Operations such as the following becom possible:
power_data.eat.power_to_freq('1h')
power_data.eat.power_to_energy()
More examples in Accessing the energy_analysis_toolbox from the Pandas API.
- class energy_analysis_toolbox.pandas.EATAccessorDataFrame(data: DataFrame)[source]#
Bases:
objectDefine a new namespace for the computation toolbox on pandas.Series.
- class energy_analysis_toolbox.pandas.EATAccessorSeries(data: Series)[source]#
Bases:
objectDefine a new namespace for the computation toolbox on pandas.Series.
- energy_to_freq(*args, **kwargs) Series[source]#
Resample an energy series to a fixed frequency.
See
energy_analysis_toolbox.energy.to_freqfor details.- Returns:
pd.Series – An Energy series resampled to a fixed frequency.
- fill_data_holes(*args, **kwargs) Series[source]#
Fill the holes in a timeseries.
See
energy_analysis_toolbox.timeseries.fill_data_holesfor details.- Returns:
pd.Series – The timeseries with the holes filled.
- intervals_over(*args, **kwargs) DataFrame[source]#
Detect intervals over a threshold.
See
energy_analysis_toolbox.timeseries.extract_features.intervals_overfor details.- Returns:
pd.DataFrame – The intervals over the threshold.
- power_to_freq(*args, **kwargs) Series[source]#
Resample a power series to a fixed frequency.
See
energy_analysis_toolbox.power.to_freqfor details.- Returns:
pd.Series – A power series resampled to a fixed frequency.
- timestep_durations(*args, **kwargs) Series[source]#
Return the series of timestep durations of a timeseries.
See
energy_analysis_toolbox.timeseries.timestep_durationsfor details.- Returns:
pd.Series – The duration of each timestep.
- to_energy(*args, **kwargs) Series[source]#
Convert a power series to an energy series.
See
energy_analysis_toolbox.power.to_energyfor details.- Returns:
pd.Series – An energy series.
- to_freq(freq: str | Timedelta | None, origin: None | Literal['floor', 'ceil'] | Timestamp = None, last_step_duration: float | None = None, method: Literal['piecewise_affine', 'piecewise_constant', 'volume_conservative', 'flow_rate_conservative'] | Callable[[Series, DatetimeIndex], Series] = 'piecewise_affine', **kwargs) Series[source]#
Resample a series to a fixed frequency with various strategies.
See
energy_analysis_toolbox.timeseries.resample.to_freqfor details.- Parameters:
freq (str, pd.Timedelta) – the freq to which the series is resampled. Must be a valid pandas frequency.
origin ({None, 'floor', 'ceil', pd.Timestamp}) –
What origin should be used for the target resampling range. The following values are possible :
None: the default. Use the first index as the data a starting point.'floor': use the first index of the data, floored to the passedfreqresolution.'ceil': use the first index of the data, ceiled to the passedfreqresolution.a
pd.Timestamp: use the passed timestamp as starting point. The code tries to localize the value to the timezone of the first index in the data. Accordingly :
if the passed value is time-naive, it is localized to the timezone of the data;
if the data is time-naive, the timezone of the passed value is ignored and it is processed as if it were time-naive.
last_step_duration (float, optional) – the duration of the last step of the resampling in (s). If
None, the duration of the former-last time-step is used. Used to deduce the end of the resampling range.method (str or callable, optional) –
Method used to interpolate the values of the resampled series. The accepted values are:
’piecewise_affine’: uses
piecewise_affine, assume the values a straight line between two points. The default method.’piecewise_constant’: uses
piecewise_constant, assume the values constante until the next point.’volume_conservative’: uses
volume_to_freq, conserve quantity of the values. Best to use it for energy timeseries.’flow_rate_conservative’: uses
flow_rate_to_freq, conserve the values time the duration between two points. Best to use it for power timeseries.
If a callable is passed, it must take a
pandas.Seriesas first argument and apandas.DatetimeIndexas second argument. See the interface ofpiecewise_affinefunction. The default is ‘piecewise_affine’.
- Returns:
pd.Series – A series resampled to a fixed frequency.