HusnaManakkot commited on
Commit
d5dec0d
·
verified ·
1 Parent(s): 5fc7c3d

Update spider.py

Browse files
Files changed (1) hide show
  1. spider.py +38 -0
spider.py CHANGED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datasets import load_dataset, Dataset
2
+ import pandas as pd
3
+
4
+ # Step 1: Download your uploaded Spider dataset
5
+ my_spider_dataset = load_dataset("HusnaManakkot/new-spider-HM", split='train')
6
+
7
+ # Step 2: Convert the dataset to a Pandas DataFrame
8
+ my_spider_df = pd.DataFrame(my_spider_dataset)
9
+
10
+ # Step 3: Add a new row to the DataFrame
11
+ new_example = {
12
+ 'db_id': 'employee_database', # Replace with the actual database ID
13
+ 'query': "SELECT AVG(salary) FROM employees WHERE join_date > '2015-01-01' AND department = 'Marketing';",
14
+ 'question': 'What is the average salary of employees who joined after 2015 and work in the Marketing department?',
15
+ 'query_toks': ['SELECT', 'AVG', '(', 'salary', ')', 'FROM', 'employees', 'WHERE', 'join_date', '>', "'2015-01-01'", 'AND', 'department', '=', "'Marketing'", ';'],
16
+ 'query_toks_no_value': ['SELECT', 'AVG', '(', 'salary', ')', 'FROM', 'employees', 'WHERE', 'join_date', '>', 'VALUE', 'AND', 'department', '=', 'VALUE', ';'],
17
+ 'question_toks': ['What', 'is', 'the', 'average', 'salary', 'of', 'employees', 'who', 'joined', 'after', '2015', 'and', 'work', 'in', 'the', 'Marketing', 'department', '?'],
18
+ 'sql': {
19
+ 'select': [(0, [(3, (0, 'salary'))])], # (agg_id, val_unit), agg_id for AVG is 0, val_unit is (column_id, column_name)
20
+ 'from': {'table_units': [('table_unit', 0)], 'conds': []}, # ('table_unit', table_id), assuming 'employees' is the first table
21
+ 'where': [(0, False, [(2, (0, 'join_date')), '>', (1, "'2015-01-01'")]), 'AND', (0, False, [(2, (0, 'department')), '=', (1, "'Marketing'")])],
22
+ 'groupBy': [],
23
+ 'having': [],
24
+ 'orderBy': [],
25
+ 'limit': None,
26
+ 'intersect': None,
27
+ 'union': None,
28
+ 'except': None
29
+ }
30
+ }
31
+
32
+ my_spider_df = my_spider_df.append(new_example, ignore_index=True)
33
+
34
+ # Step 4: Convert the modified DataFrame back to a Hugging Face dataset
35
+ modified_spider_dataset = Dataset.from_pandas(my_spider_df)
36
+
37
+ # Step 5: Push the modified dataset back to your Hugging Face account
38
+ modified_spider_dataset.push_to_hub("HusnaManakkot/new-spider-HM")