From cadfcc2025708093ddf0ab7493f8ce7b3da3ef50 Mon Sep 17 00:00:00 2001 From: Yumibyte Date: Mon, 17 Jun 2019 13:08:22 -0700 Subject: [PATCH] Filter by keyword The function will take the dataframe from list_to_df and filter through it with a given keyword. This is important for filtering long lists with common groupings for the user. --- geo-app-api/app.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/geo-app-api/app.py b/geo-app-api/app.py index 35a0b6a..67c86be 100644 --- a/geo-app-api/app.py +++ b/geo-app-api/app.py @@ -72,6 +72,12 @@ def list_to_df(values): # print header return df +def filter_value(df): + + val = input('keyword: ') #this keyword will only be searched under the specified column! + + filtered = (df[df.column_name==val]) #column_name needs to be stated + return filtered # TODO move this to a module # TODO write some test cases for this