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

bugfix: read fixed-length string arrays as bytes #950

Closed
wants to merge 2 commits into from

Conversation

gszep
Copy link

@gszep gszep commented Mar 15, 2023

There is a bug in pandas that prevents fixed-length string arrays np.dtype("S") from being read properly. For some reason the dataframe does the casting properly only if the array is set after dataframe creation.

x = np.array([b"123",b"e23423"], dtype="S")
df = pd.DataFrame({"a": x})
df.types # sees x as object
df = pd.DataFrame({})
df["a"] = x
df.dtypes # correct type

This PR is a workaround until the pandas bug is addressed

@gszep
Copy link
Author

gszep commented Mar 15, 2023

reported in pandas pandas-dev/pandas#51994

@codecov
Copy link

codecov bot commented Mar 15, 2023

Codecov Report

Merging #950 (468cb5c) into main (dcee1e5) will increase coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head 468cb5c differs from pull request most recent head 1794406. Consider uploading reports for the commit 1794406 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #950      +/-   ##
==========================================
+ Coverage   84.15%   84.17%   +0.01%     
==========================================
  Files          34       34              
  Lines        4709     4713       +4     
==========================================
+ Hits         3963     3967       +4     
  Misses        746      746              
Impacted Files Coverage Δ
anndata/_io/specs/methods.py 87.90% <100.00%> (+0.12%) ⬆️

... and 1 file with indirect coverage changes

@gszep gszep closed this Apr 15, 2023
@gszep gszep deleted the master branch April 15, 2023 15:21
@gszep gszep restored the master branch April 15, 2023 15:21
@gszep gszep reopened this Apr 15, 2023
@gszep gszep closed this Apr 15, 2023
@gszep gszep deleted the master branch April 15, 2023 15:23
@gszep
Copy link
Author

gszep commented Apr 15, 2023

moved to #982 so I can delete master in favor of main

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 this pull request may close these issues.

1 participant