Skip to content

ENH: Add support for DataFrame(ExtensionArray) #30305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

proost
Copy link
Contributor

@proost proost commented Dec 17, 2019

Problem:
In core.frame

        elif isinstance(data, abc.Iterable) and not isinstance(data, (str, bytes)):
            if not isinstance(data, (abc.Sequence)):
                data = list(data)

Categorical Object cast as list. So In core.construction it is not identified as Categorical.

@@ -450,7 +450,7 @@ def __init__(

# For data is list-like, or Iterable (will consume into list)
elif isinstance(data, abc.Iterable) and not isinstance(data, (str, bytes)):
if not isinstance(data, abc.Sequence):
if not isinstance(data, (abc.Sequence, Categorical)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be any extension dtype? Not just categorical?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TomAugspurger
Yes. you are right. Thank you for pointing out. So I change it. Also add test case too except "DatetimeArray" and "TimedeltaArray". Because these are currently experimental and also these have no reshape method so can't use "assert_frame_equal".

@proost proost force-pushed the ENH-Dataframe-categorical-constructor branch from fb6a3ee to 8d1abe2 Compare December 18, 2019 07:30
@proost proost force-pushed the ENH-Dataframe-categorical-constructor branch from 8d1abe2 to 35d502f Compare December 18, 2019 09:11
@topper-123 topper-123 changed the title ENH: Add support for DataFrame(Categorical) ENH: Add support for DataFrame(ExtensionArray) Dec 18, 2019
@topper-123 topper-123 merged commit 18bd98f into pandas-dev:master Dec 18, 2019
@topper-123
Copy link
Contributor

Thanks, @proost

@topper-123 topper-123 added the Constructors Series/DataFrame/Index/pd.array Constructors label Dec 18, 2019
@topper-123 topper-123 added this to the 1.0 milestone Dec 18, 2019
@topper-123 topper-123 added the DataFrame DataFrame data structure label Dec 18, 2019
@proost proost deleted the ENH-Dataframe-categorical-constructor branch December 19, 2019 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Constructors Series/DataFrame/Index/pd.array Constructors DataFrame DataFrame data structure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for DataFrame(Categorical)
3 participants