pydata / pydata/xarray

`from_dataframe` gets a `cast_extension_array` argument

Open
#10,398 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

Is your feature request related to a problem?

To resolve the ongoing discussion around extension array casting, an option that has arisen would be to add a cast_extension_array argument (see https://github.com/pydata/xarray/issues/10301#issuecomment-2866569942 as well) to from_dataframe in order to give users "old" behavior (see #10301 for an exmaple where this might help).

Whether this is default true or false is up for debate probably but I think this is a great feature independent of the chaos that has arisen.

Describe the solution you'd like

from_dataframe gets a cast_extension_array argument

Describe alternatives you've considered

The alternative would basically be continuing to fix things as they arise and being totally permissive. But that is what is going to likely happen anyway (i.e., you can set on a Dataset with an extension array type anyway given this feature, no issue).

Additional context

cc @dcherian @keewis

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the from_dataframe entry point and read the linked #10301 discussion to understand the extension-array casting behavior and unresolved default. Done means the new argument is supported with an agreed default and tests demonstrate both the existing and alternative casting behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python
Domain
api, data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.