Can only use .str accessor with string values, which use np.object_ dtype in pandas
See original GitHub issueSystem information
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): CentOS Linux release 7.5.1804 (Core)
- Modin installed from (source or binary): pip install modin
- Modin version: 0.3.0
- Python version: 3.5.2
- Exact command to reproduce:
df['foo'] = df['foo'].str.replace('.', ',')
Describe the problem
This issue follows the #414
And yes df['foo'] = df['foo'].str.replace('.', ','
) worked with pandas.
Actually all my code used to worked with pandas ^^
Source code / logs
Can only use .str accessor with string values, which use np.object_ dtype in pandas
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
AttributeError: Can only use .str accessor with string values ...
As the error states, you can only use .str with string columns, and you have a float64 . There won't be any commas...
Read more >How to Fix: Can only use .str accessor with string values
This error usually occurs when you attempt to replace a pattern in a string column of a pandas DataFrame, but the column you're...
Read more >AttributeError: Can only use .str accessor with string values ...
Coding example for the question AttributeError: Can only use .str accessor with string values, which use np.object_ dtype in pandas-Pandas,Python.
Read more >Python – Pandas error: Can only use .str accessor with string ...
Python – Pandas error: Can only use .str accessor with string values, which use np.object_ dtype in pandas. pandaspython. I have data ...
Read more >Working with text data — pandas 1.5.2 documentation
You can also use StringDtype / "string" as the dtype on non-string data and it will be ... Since df.columns is an Index...
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
print(df['foo'].dtype)
gives “object”df['foo'] = df['foo'].apply(str).str.replace('.', ',')
actually works 😃I see, the encoding does not allow testing on 0.2.5.
This is an interesting issue, because it is using pandas for that
series
code.What does
print(df['foo'].dtype)
print? It is giving an error related to thedtype
.Also, does this fix the issue:
It will force the column to string dtype because it is not recognizing it as a string column.