1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
Author: Diane Trout <diane@ghic.org>
Description: Debian appears to be using a newer version of pandas
than anndata is assuming. Pandas deprecated a function call that
anndata assumed would not have warnings which causes tests to fail.
We can just use the new API because we don't have to worry about supporting
earlier versions of pandas.
Forwarded: https://github.com/theislab/anndata/issues/443
--- a/anndata/_core/anndata.py
+++ b/anndata/_core/anndata.py
@@ -18,7 +18,7 @@
import numpy as np
from numpy import ma
import pandas as pd
-from pandas.api.types import is_string_dtype, is_categorical
+from pandas.api.types import is_string_dtype, is_categorical_dtype
from scipy import sparse
from scipy.sparse import issparse
@@ -1088,10 +1088,10 @@
return AnnData(self, oidx=oidx, vidx=vidx, asview=True)
def _remove_unused_categories(self, df_full, df_sub, uns):
- from pandas.api.types import is_categorical
+ from pandas.api.types import is_categorical_dtype
for k in df_full:
- if not is_categorical(df_full[k]):
+ if not is_categorical_dtype(df_full[k]):
continue
all_categories = df_full[k].cat.categories
df_sub[k].cat.remove_unused_categories(inplace=True)
@@ -1189,7 +1189,7 @@
string_cols = [
key
for key in df.columns
- if is_string_dtype(df[key]) and not is_categorical(df[key])
+ if is_string_dtype(df[key]) and not is_categorical_dtype(df[key])
]
for key in string_cols:
# make sure we only have strings
|