Datasets:
Dataset schema inconsistency: salary declared as int but contains float values
#2
by
fconti
- opened
Dataset schema inconsistency: salary declared as int but contains float values
Description
While loading the dataset datapizza-ai-lab/salaries using datasets.load_dataset, the dataset generation fails with an ArrowInvalid error related to type casting.
The root cause is an inconsistency between the declared schema and the actual data:
- The schema declares
salaryasint - The data contains float values, including non-integer values (e.g. with decimals)
This causes Apache Arrow to fail when casting float β int64.
Error
ArrowInvalid: Float value 28546.310000 was truncated converting to int64
The error occurs during load_dataset()
Example problematic records
Row n 25370
{
...
"salary":28546.31,
...
}
Suggested fix
One of the following (preferred option first):
Update the schema to:
salary float RAL (Gross Annual Salary) in EUR
Alternatively, normalize the data so that salary is always an integer (e.g. rounding), if that is the intended semantics.
Workaround (for users)
features = Features({
"jobTitle": Value("string"),
"monthsOfExperience": Value("int64"),
"educationType": Value("string"),
"companyIndustry": Value("string"),
"companySize": Value("string"),
"province": Value("string"),
"workMode": Value("string"),
"technologies": Sequence(Value("string")),
"salary": Value("float64"), # π FIX
"age": Value("int64"),
"gender": Value("string"),
"aiUsageFrequency": Value("int64"),
"aiTechnologies": Sequence(Value("string")),
"aiTaskTypes": Sequence(Value("string")),
"aiUpdateSources": Sequence(Value("string")),
"admiredTechnologies": Sequence(Value("string")),
"editor": Value("string"),
"rating": Value("int64"),
"valid": Value("bool"),
"submittedAt": Value("string"),
})
dataset = load_dataset(
"datapizza-ai-lab/salaries",
features=features
)
Should be resolved!
Thanks
Thanks!
fconti
changed discussion status to
closed