module mlhelper.missing
¶
Short summary¶
module pyensae.mlhelper.missing
Missing values and pandas.
Functions¶
function |
truncated documentation |
---|---|
After aggregation, it usually happens that the series is sparse. This function adds rows for missing time. |
Documentation¶
Missing values and pandas.
- pyensae.mlhelper.missing.add_missing_indices(df, column, all_values, values=None, fillvalue=nan)¶
After aggregation, it usually happens that the series is sparse. This function adds rows for missing time.
- Parameters:
df – dataframe to extend
column – column with time
all_values – all the values we want
values – columns which contain the values, the others are considered as the keys
- Returns:
new dataframe
Add missing values in one column.
<<<
import pandas from pyensae.mlhelper import add_missing_indices df = pandas.DataFrame([{"x": 3, "y": 4, "z": 1}, {"x": 5, "y": 6, "z": 2}]) df2 = add_missing_indices(df, "x", [3, 4, 5, 6]) print(df2)
>>>
x y z 0 3 4 1 4 3 6 2 1 4 4 1 5 4 6 2 2 5 4 1 6 5 6 2 3 6 4 1 7 6 6 2
<<<
import pandas from pyensae.mlhelper import add_missing_indices df = pandas.DataFrame([{"x": 3, "y": 4, "z": 1}, {"x": 5, "y": 6, "z": 2}]) df2 = add_missing_indices(df, "x", values=["y"], all_values=[3, 4, 5, 6]) print(df2)
>>>
x y z 0 3 4.0 1 4 3 NaN 2 1 4 NaN 1 5 4 NaN 2 2 5 NaN 1 6 5 6.0 2 3 6 NaN 1 7 6 NaN 2