Repository navigation
Spark compatibility with pandas extension dtypes - #9590
Open
jrbourbeau wants to merge 9 commits into
Open
jrbourbeau wants to merge 9 commits into
jrbourbeau wants to merge 9 commits into
Conversation
jrbourbeau
commented
Oct 24, 2022
|
|
||
| echo "py.test dask --runslow $XTRATESTARGS" | ||
| py.test dask --runslow $XTRATESTARGS | ||
| py.test dask/tests/test_spark_compat.py --runslow $XTRATESTARGS |
Member
Author
There was a problem hiding this comment.
This is just a temporary change for convenience. This should be reverted before merging this PR
|
here's a reproducible example of the issue using pyarrow import pyarrow as pa
import dask.dataframe as dd
import pandas as pd
# Generate a parquet with a nullable int dtype
pq.write_to_dataset(
pa.Table.from_arrays([
[0, 1, 2, None, 4, 5, 6, 7, 8, 9],
['a'] * 5 + ['b'] * 5
], names=['x1', 'part']),
"test.parquet",
partition_cols = ['part']
)
# Read in parquet and call a function that requires an int col
df = dd.read_parquet("test.parquet") \
.assign(
some_date = pd.to_datetime('2022-01-01').to_period('M'),
inc_date = lambda d: d['some_date'] + d['x1']
)
df.head() # fails, partition 1 casts x1 as a float
df.tail() # works, partition 2 casts x2 as an int
When converting pyarrow to pandas via |
This was referenced Oct 31, 2022
Member
|
@jrbourbeau I'm curious, what is the status here? Do you think it would be possible to hand this off to someone else? If so, what would you suggest as a course of action? |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This test demonstrates that, when Parquet datasets with extension dtypes are written with Spark, Dask isn't currently able to read in extension dtypes as expected. Instead, things get dtypes get downcasted (e.g. a column that starts out as
Float64is read in by Dask asfloat)