Skip to content
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

AttributeError: 'DataFrameView' object has no attribute '_view_args' with Pandas 2.1.2+ #1223

Closed
3 tasks done
Zethson opened this issue Nov 1, 2023 · 4 comments
Closed
3 tasks done

Comments

@Zethson
Copy link
Member

Zethson commented Nov 1, 2023

Please make sure these conditions are met

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of anndata.
  • (optional) I have confirmed this bug exists on the master branch of anndata.

Report

Started appearing in several of ehrapy's tests with 2.1.2.

Traceback:

ehrapy/anndata/anndata_ext.py:226: in move_to_obs
    adata.obs[num_var] = adata.obs[num_var].apply(pd.to_numeric, errors="ignore", downcast="float")
../../miniconda3/envs/ehrapy/lib/python3.11/site-packages/anndata/_core/views.py:69: in __setitem__
    if self._view_args is None:

    @final
    def __getattr__(self, name: str):
        """
        After regular attribute access, try looking up the name
        This allows simpler access to columns for interactive use.
        """
        # Note: obj.x will always call obj.__getattribute__('x') prior to
        # calling obj.__getattr__('x').
        if (
            name not in self._internal_names_set
            and name not in self._metadata
            and name not in self._accessors
            and self._info_axis._can_hold_identifiers_and_holds_name(name)
        ):
            return self[name]
>       return object.__getattribute__(self, name)
E       AttributeError: 'DataFrameView' object has no attribute '_view_args'

../../miniconda3/envs/ehrapy/lib/python3.11/site-packages/pandas/core/generic.py:6204: AttributeError

Versions

Latest anndata

Pandas 2.1.2 (aka the forbidden one) and it works with 2.1.1

But it's not #1210

@flying-sheep
Copy link
Member

I think the root cause is the same: pandas-dev/pandas#55763

'DataFrameView' object has no attribute '_view_args' sounds like “.copy or so made a new DataFrameView when it should have made a DataFrame, and didn’t set all fields”

@ivirshup
Copy link
Member

ivirshup commented Nov 2, 2023

Would be nice to confirm if this is fixed by pandas-dev/pandas#55764

@Zethson
Copy link
Member Author

Zethson commented Nov 2, 2023

@ivirshup tested and it does indeed :) Thank you

@flying-sheep
Copy link
Member

In that case, closing as duplicate of #1210

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants