Datasets:
Tasks:
Text2Text Generation
Modalities:
Text
Formats:
parquet
Languages:
English
Size:
1K - 10K
Tags:
text-to-sql
License:
File size: 1,735 Bytes
d5dec0d a56e568 d5dec0d a56e568 d5dec0d a56e568 d5dec0d a56e568 d5dec0d a56e568 d5dec0d a56e568 d5dec0d a56e568 d5dec0d a56e568 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import pandas as pd
from datasets import Dataset
# Step 1: Read the Parquet files
train_df = pd.read_parquet('train-00000-of-00001.parquet')
validation_df = pd.read_parquet('validation-00000-of-00001.parquet')
# Step 2: Add the new row to the training DataFrame
new_example = {
'db_id': 'hr_1', # Replace with the actual database ID
'query': "SELECT COUNT(*) FROM employees WHERE department = 'Sales' AND salary > 50000;",
'question': 'How many employees in the Sales department have a salary greater than $50,000?',
'query_toks': ['SELECT', 'COUNT', '(', '*', ')', 'FROM', 'employees', 'WHERE', 'department', '=', "'Sales'", 'AND', 'salary', '>', '50000', ';'],
'query_toks_no_value': ['SELECT', 'COUNT', '(', '*', ')', 'FROM', 'employees', 'WHERE', 'department', '=', 'VALUE', 'AND', 'salary', '>', 'VALUE', ';'],
'question_toks': ['How', 'many', 'employees', 'in', 'the', 'Sales', 'department', 'have', 'a', 'salary', 'greater', 'than', '$50,000', '?'],
'sql': {
'select': [(0, [(3, (0, '*'))])], # (agg_id, val_unit), agg_id for COUNT is 0, val_unit is (column_id, column_name)
'from': {'table_units': [('table_unit', 0)], 'conds': []}, # ('table_unit', table_id), assuming 'employees' is the first table
'where': [(0, False, [(2, (0, 'department')), '=', (1, "'Sales'")]), 'AND', (0, False, [(2, (0, 'salary')), '>', (1, '50000')])],
'groupBy': [],
'having': [],
'orderBy': [],
'limit': None,
'intersect': None,
'union': None,
'except': None
}
}
train_df = train_df.append(new_example, ignore_index=True)
# Step 3: Write the modified DataFrame back to Parquet
train_df.to_parquet('train-00000-of-00001.parquet')
|