Skip to content

Commit

Permalink
Fixes for pandas 1.3.0 (scverse#1918)
Browse files Browse the repository at this point in the history
* Fixes for pandas 1.3.0
  • Loading branch information
ivirshup authored Jul 5, 2021
1 parent 87396a8 commit c9b5913
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/release-notes/1.8.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@

.. rubric:: Bug fixes

- Workarounds for some changes/ bugs in pandas 1.3 :pr:`1918` :smaller:`I Virshup`

.. rubric:: Performance Enhancements
2 changes: 1 addition & 1 deletion scanpy/plotting/_anndata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,7 @@ def _prepare_dataframe(
categorical.name = groupby[0]
else:
# join the groupby values using "_" to make a new 'category'
categorical = obs_tidy[groupby].agg('_'.join, axis=1).astype('category')
categorical = obs_tidy[groupby].apply('_'.join, axis=1).astype('category')
categorical.name = "_".join(groupby)

# preserve category order
Expand Down
6 changes: 3 additions & 3 deletions scanpy/preprocessing/_qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def describe_obs(
obs_metrics[f"log1p_n_{var_type}_by_{expr_type}"] = np.log1p(
obs_metrics[f"n_{var_type}_by_{expr_type}"]
)
obs_metrics[f"total_{expr_type}"] = X.sum(axis=1)
obs_metrics[f"total_{expr_type}"] = np.ravel(X.sum(axis=1))
if log1p:
obs_metrics[f"log1p_total_{expr_type}"] = np.log1p(
obs_metrics[f"total_{expr_type}"]
Expand All @@ -119,8 +119,8 @@ def describe_obs(
proportions[:, i] * 100
)
for qc_var in qc_vars:
obs_metrics[f"total_{expr_type}_{qc_var}"] = X[:, adata.var[qc_var].values].sum(
axis=1
obs_metrics[f"total_{expr_type}_{qc_var}"] = np.ravel(
X[:, adata.var[qc_var].values].sum(axis=1)
)
if log1p:
obs_metrics[f"log1p_total_{expr_type}_{qc_var}"] = np.log1p(
Expand Down

0 comments on commit c9b5913

Please sign in to comment.