From 02c4a6c53bbc99c7d851abcb09985529c7258c93 Mon Sep 17 00:00:00 2001 From: GeorgiosEfstathiadis <54844705+GeorgeEfstathiadis@users.noreply.github.com> Date: Fri, 16 Feb 2024 10:13:09 -0500 Subject: [PATCH] Bug when empty row doesn't have correct number of NAs (#242) --- forest/jasmine/traj2stats.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/forest/jasmine/traj2stats.py b/forest/jasmine/traj2stats.py index 43852c59..6ffaf2e1 100644 --- a/forest/jasmine/traj2stats.py +++ b/forest/jasmine/traj2stats.py @@ -1196,6 +1196,9 @@ def gps_summaries( # if there is no data in the day, then we need to # to add empty rows to the dataframe with 21 columns res = [year, month, day] + [0] * 18 + + if parameters.pcr_bool: + res += [pd.NA] * 2 if places_of_interest is not None: # add empty data for places of interest # for daytime/nighttime + other @@ -1205,7 +1208,15 @@ def gps_summaries( elif sum(index_rows) == 0 and not parameters.split_day_night: # There is no data and it is daily data, so we need to add empty # rows - res = [year, month, day] + [0] * 3 + [pd.NA] * 15 + if frequency == Frequency.DAILY: + res = [year, month, day] + [0] * 3 + [pd.NA] * 15 + + if parameters.pcr_bool: + res += [pd.NA] * 2 + else: + # if there is no data in the day, then we need to + # add empty rows to the dataframe with 21 columns + res = [year, month, day, hour] + [0] + [pd.NA] * 11 if places_of_interest is not None: # add empty data for places of interest