Skip to content

Commit

Permalink
reset_index on measurements_amount() dataframe, fixes #64
Browse files Browse the repository at this point in the history
  • Loading branch information
veenstrajelmer committed Mar 11, 2024
1 parent fad611e commit 2f2f594
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ddlpy/ddlpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,18 @@ def measurements_amount(location, start_date, end_date, period="Jaar"):
# combine columns to a period string
df["Groeperingsperiode"] = df["Groeperingsperiode.Jaarnummer"].apply(lambda x: f"{x:04d}")
if period in ["Maand", "Dag"]:
df["Groeperingsperiode"] = df["Groeperingsperiode"] + "-" + df["Groeperingsperiode.Maandnummer"].apply(lambda x: f"{x:02d}")
df["Groeperingsperiode"] = (df["Groeperingsperiode"] + "-" +
df["Groeperingsperiode.Maandnummer"].apply(lambda x: f"{x:02d}"))
if period in ["Dag"]:
df["Groeperingsperiode"] = df["Groeperingsperiode"] + "-" + df["Groeperingsperiode.Dag"].apply(lambda x: f"{x:02d}")
df["Groeperingsperiode"] = (df["Groeperingsperiode"] + "-" +
df["Groeperingsperiode.Dag"].apply(lambda x: f"{x:02d}"))

# select columns from dataframe and append to list
df = df[["Groeperingsperiode","AantalMetingen"]]
df_list.append(df)

# concatenate
amount_all = pd.concat(df_list).sort_values("Groeperingsperiode")
amount_all = pd.concat(df_list).sort_values("Groeperingsperiode").reset_index(drop=True)
return amount_all


Expand Down

0 comments on commit 2f2f594

Please sign in to comment.