Series.str.decode() turns arrays of strings to NaN and fails on byte strings
See original GitHub issueHello,
this looks like a bug:
x = np.array(['x','y'])
pd.Series(x).str.decode(encoding='UTF-8',errors='strict')
0 NaN
1 NaN
dtype: float64
the line above is also used in pytables.py:
data = Series(data).str.decode(encoding, errors=errors).values
… and leads to an error when reading hdf-files written with pandas <0.23 In some cases the text data was stored as byte string (i.e. ‘x = np.array([b’x’, b’y’]) ) which raises the following:
AttributeError: Can only use .str accessor with string values, which use np.object_ dtype in pandas
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:9 (2 by maintainers)
Top Results From Across the Web
How to translate "bytes" objects into literal strings in pandas ...
You can use vectorised str.decode to decode byte strings into ordinary strings: df['COLUMN1'].str.decode("utf-8"). To do this for multiple ...
Read more >Why does .decode() result in NaN values for byte strings that ...
I have a MS SQL database that I want to query with Python. I use the following snippet: cnxn = pypyodbc.connect("Driver={SQL Server Native...
Read more >Python | Pandas Series.str.decode() - GeeksforGeeks
str.decode() function to decode the character strings in the underlying data of the given series object. Use 'UTF-8' encoding method.
Read more >Convert Bytes to String [Python] - YouTube
Quick Sol: The decode () method allows us to convert a byte string object (encoded in a certain format) to a simple string...
Read more >Built-in Types — Python 3.11.1 documentation
... to a string (with the repr() function or the slightly different str() ... not a == b is interpreted as not (a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello, is there any update on the issue? Since i ran into the same problem it would be great if someone could help to solve it…
finally done a little research, it’s taking the “except-route” here:
the first except is triggered by
lib.map_infer_mask
which in my installation is this file \python3\lib\site-packages\pandas_libs\lib.cp37-win_amd64.pyd