bstraehle commited on
Commit
39d8524
·
verified ·
1 Parent(s): 03e18df

Update hugging_face.py

Browse files
Files changed (1) hide show
  1. hugging_face.py +10 -6
hugging_face.py CHANGED
@@ -1,13 +1,15 @@
1
  import pandas as pd
 
2
  from datasets import load_dataset
3
 
4
- def load_data():
5
  dataset = load_dataset("MongoDB/airbnb_embeddings", streaming=True, split="train")
6
  dataset = dataset.take(100)
7
  dataset_df = pd.DataFrame(dataset)
8
  dataset_df.head(5)
9
  print("Columns:", dataset_df.columns)
10
  records = dataset_df.to_dict(orient='records')
 
11
  # To handle catch `NaT` values
12
  for record in records:
13
  for key, value in record.items():
@@ -19,10 +21,12 @@ def load_data():
19
  else:
20
  if pd.isnull(value):
21
  record[key] = None
 
22
  try:
23
- # Convert each dictionary to a Movie instance
24
- listings = [Listing(**record).dict() for record in records]
25
- # Get an overview of a single datapoint
26
- print(listings[0].keys())
 
27
  except ValidationError as e:
28
- print(e)
 
1
  import pandas as pd
2
+
3
  from datasets import load_dataset
4
 
5
+ def get_listings():
6
  dataset = load_dataset("MongoDB/airbnb_embeddings", streaming=True, split="train")
7
  dataset = dataset.take(100)
8
  dataset_df = pd.DataFrame(dataset)
9
  dataset_df.head(5)
10
  print("Columns:", dataset_df.columns)
11
  records = dataset_df.to_dict(orient='records')
12
+
13
  # To handle catch `NaT` values
14
  for record in records:
15
  for key, value in record.items():
 
21
  else:
22
  if pd.isnull(value):
23
  record[key] = None
24
+
25
  try:
26
+ # Convert each dictionary to a Movie instance
27
+ listings = [Listing(**record).dict() for record in records]
28
+ # Get an overview of a single datapoint
29
+ print(listings[0].keys())
30
+ return listings
31
  except ValidationError as e:
32
+ print(e)