Skip to content

Instantly share code, notes, and snippets.

@vnegi10
Last active August 6, 2023 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vnegi10/93942918223213cbfce248a0ba0522a8 to your computer and use it in GitHub Desktop.
Save vnegi10/93942918223213cbfce248a0ba0522a8 to your computer and use it in GitHub Desktop.
function process_gas_df(df_all_gas::DataFrame)
df_gas = deepcopy(df_all_gas)
# Temperature is 10x in original data
df_gas[!, :T] = df_gas[!, :T] ./ 10
# Convert from kWh to m^3
conversion_factor = 0.10058
df_gas[!, :ch] = df_gas[!, :ch] .* conversion_factor
df_gas[!, :hw] = df_gas[!, :hw] .* conversion_factor
# Convert to Date object
df_gas[!, :d] = Date.(df_gas[!, :d], "dd-mm-yyyy")
# Rename all colums
rename!(df_gas, Dict(:T => "OutsideTemperature",
:ch => "CentralHeating",
:hw => "HotWater",
:d => "Date"))
# Get column with day names
day = map(x -> Dates.dayname(x), df_gas[!, :Date])
insertcols!(df_gas, ncol(df_gas), :Day => day)
return df_gas
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment