Skip to content

Scanpy uses deprecated Pandas APIs #2788

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

Closed
5 tasks done
flying-sheep opened this issue Dec 19, 2023 · 0 comments · Fixed by #2789
Closed
5 tasks done

Scanpy uses deprecated Pandas APIs #2788

flying-sheep opened this issue Dec 19, 2023 · 0 comments · Fixed by #2789

Comments

@flying-sheep
Copy link
Member

flying-sheep commented Dec 19, 2023

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

Many scanpy functions raise warnings, to the point that people ignore them when they happen

  • Fix pandas function deprecation warnings #2678
    • Deprecated is_categorical_dtype
    • Deprecated pandas.value_counts
  • Fix more pandas warnings #2789
    • Deprecated the default of observed=False in DataFrame.groupby() and Series.groupby(); this will default to True in a future version (GH 43999)

      Setting observed=True is probably unproblematic, we don’t want to handle categories that aren’t in the data, except maybe in plotting (but then we don’t use groupby)

    • Deprecated some_series[0]: “Series.__getitem__ treating keys as positions is deprecated”

    • The default value of 'ignore' for the na_action parameter in pandas.Categorical.map is deprecated and will be changed to 'None' in a future version. Please set na_action to the desired value to avoid seeing this warning

    • df = df.groupby('gene').agg( (in SeriesGroupBy.agg?) The provided callable <function nansum at 0x7f50a03cb7e0> is currently using SeriesGroupBy.sum. In a future version of pandas, the provided callable will be used directly. To keep current behavior pass 'sum' instead.

    • same for nanmean/SeriesGroupBy.mean.

    • scanpy/tests/test_highly_variable_genes.py:59: SettingWithCopyWarning (in adata.obs.batch.loc[::2] = "b") A value is trying to be set on a copy of a slice from a DataFrame. See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy

Versions

-----
anndata     0.10.3
scanpy      1.10.0.dev178+ga073532a
-----
PIL                 10.1.0
asciitree           NA
cloudpickle         3.0.0
cycler              0.12.1
cython_runtime      NA
dask                2023.12.1
dateutil            2.8.2
fasteners           0.19
h5py                3.10.0
igraph              0.10.8
iniconfig           NA
jinja2              3.1.2
joblib              1.3.2
kiwisolver          1.4.5
legacy_api_wrap     NA
leidenalg           0.10.1
llvmlite            0.41.1
markupsafe          2.1.3
matplotlib          3.8.2
mpl_toolkits        NA
msgpack             1.0.7
natsort             8.4.0
numba               0.58.1
numcodecs           0.12.1
numpy               1.26.2
packaging           23.2
pandas              2.1.4
pluggy              1.3.0
psutil              5.9.7
py                  NA
pyparsing           3.1.1
pytest              7.4.3
pytz                2023.3.post1
scipy               1.11.4
session_info        1.0.0
setuptools          69.0.2
setuptools_scm      NA
six                 1.16.0
sklearn             1.3.2
sparse              0.14.0
tblib               3.0.0
texttable           1.7.0
threadpoolctl       3.2.0
tlz                 0.12.0
toolz               0.12.0
typing_extensions   NA
wcwidth             0.2.12
yaml                6.0.1
zarr                2.16.1
zipp                NA
-----
Python 3.11.6 (main, Nov 14 2023, 09:36:21) [GCC 13.2.1 20230801]
Linux-6.6.7-zen1-1-zen-x86_64-with-glibc2.38
-----
Session information updated at 2023-12-19 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant