Creating a DataFrame column as the running mean of another column

With vanilla DataFrames.jl it would be in your chain:

transform!(:Cases => (x -> runmean(x, 5)) => :CasesRunMean)

or

@aside _.CasesRunMean = runmean(_.Cases, 5)

With e.g. DataFramesMeta.jl it would be:

@transform!(:CasesRunMean = runmean(:Cases, 5))

(not tested as your code is not reproducible, so please comment if it does not work :smile:)


and

subset(:Date => d -> d.>= Date(2021, 8, 1))

can be written as

subset(:Date => ByRow(>=(Date(2021, 8, 1)))

or in DataFramesMeta.jl

@rsubset(:Date >= (Date(2021, 8, 1))
1 Like