Merge branch 'feature/doryab_location_empty_df_fix' into develop

Adding the branch to fix infer home locations and empty dataframe.
pull/130/head
nikunjgoel95 2021-03-19 11:17:43 -04:00
commit 7815c380a2
2 changed files with 24 additions and 19 deletions

View File

@ -111,6 +111,9 @@ def haversine(lon1,lat1,lon2,lat2):
origDf = pd.read_csv(snakemake.input[0])
filteredDf = filterDatafromDf(origDf)
if filteredDf.empty:
filteredDf.to_csv(snakemake.output[0])
else:
dbscan_eps = snakemake.params["dbscan_eps"]
dbscan_minsamples = snakemake.params["dbscan_minsamples"]
threshold_static = snakemake.params["threshold_static"]

View File

@ -188,12 +188,14 @@ def len_stay_timeattopn(locationData,maximum_gap_allowed,maximum_row_duration):
calculationDf.loc[calculationDf.timeInSeconds >= maximum_gap_allowed,'timeInSeconds'] = maximum_row_duration
timeArray = calculationDf.groupby('location_label')['timeInSeconds'].sum().reset_index()['timeInSeconds'].sort_values(ascending=False)/60
if len(timeArray) > 2:
if len(timeArray) == 3:
return (timeArray[0],timeArray[1],timeArray[2],timeArray.max(),timeArray.min(),timeArray.std(),timeArray.mean())
elif len(timeArray)==2:
return (timeArray[0],timeArray[1],None,timeArray.max(),timeArray.min(),timeArray.std(),timeArray.mean())
else:
elif len(timeArray)==1:
return (timeArray[0],None,None,timeArray.max(),timeArray.min(),timeArray.std(),timeArray.mean())
else:
return (None,None,None,timeArray.max(),timeArray.min(),timeArray.std(),timeArray.mean())
def getMinutesData(locationData):