Léo Bourrel commited on
Commit
d29e7cc
·
1 Parent(s): 687f595

fix: str instead of list

Browse files
Files changed (1) hide show
  1. src/park_statistics.py +5 -6
src/park_statistics.py CHANGED
@@ -10,13 +10,11 @@ from typing import Any
10
 
11
  def get_elements(x: str, key: str = "elements") -> Any:
12
  try:
13
- result = ast.literal_eval(x)
14
- if isinstance(result, dict):
15
- return result[key]
16
- elif isinstance(result, str):
17
  return [result]
18
- elif isinstance(result, list):
19
- return result
20
  except:
21
  return []
22
 
@@ -37,6 +35,7 @@ def get_plot_from_most_common_elements(df: pd.DataFrame, column: str, key: str =
37
  labels={"count": "# Objects", column: "Built Elements"},
38
  )
39
 
 
40
  def aggregate_fauna_elements(df: pd.DataFrame) -> dict:
41
  fauna_elements = {}
42
  fauna = df["fauna_identification"].apply(lambda x: ast.literal_eval(x)["fauna"])
 
10
 
11
  def get_elements(x: str, key: str = "elements") -> Any:
12
  try:
13
+ result = ast.literal_eval(x)[key]
14
+ print(type(result), result)
15
+ if isinstance(result, str):
 
16
  return [result]
17
+ return result
 
18
  except:
19
  return []
20
 
 
35
  labels={"count": "# Objects", column: "Built Elements"},
36
  )
37
 
38
+
39
  def aggregate_fauna_elements(df: pd.DataFrame) -> dict:
40
  fauna_elements = {}
41
  fauna = df["fauna_identification"].apply(lambda x: ast.literal_eval(x)["fauna"])