I need to apply some processes for each month of a dataframe. The data has to be filtered monthly or else the results will be wrong.
My idea was to create a loop to then append those DF's and finally generate what is needed for my reports but it seems it is not possible to do it via f strings and i am out of ideas:
for i, a, m in it.zip_longest(range(1,3,1), range(1,3,1), range(1, 13,1)):
f"df{i}" = df\
.select("var0","var1","var2","varN","datetime")
.filter((col("datetime") == f"202{str(a)}-{str(m).zfill(2)}-01") &
col("datetime")==f"202{str(a)}-{str(m).zfill(2)}-01")
The code idea is to create DF's sequentially, up to the number of months needed, starting in 2022-01 up to 2022-12 then switching to 2023-01 up to 2023-12.
I have the following error:
SyntaxError: can't assign to function call