question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can only use .str accessor with string values, which use np.object_ dtype in pandas

See original GitHub issue

System 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:closed
  • Created 5 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

7reactions
Clem-Dcommented, Jan 31, 2019

print(df['foo'].dtype) gives “object” df['foo'] = df['foo'].apply(str).str.replace('.', ',') actually works 😃

5reactions
devin-petersohncommented, Jan 30, 2019

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 the dtype.

Also, does this fix the issue:

df['foo'] = df['foo'].apply(str).str.replace('.', ',')

It will force the column to string dtype because it is not recognizing it as a string column.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found