dc_listings<"price">.str.replace(",", "")AttributeError: have the right to only usage .str accessor with string values, which usage np.object_ dtype in pandasHere space the top 5 rows of my price column.
This ridge overflow thread recommends to inspect if my column has NAN values however non the the values in my column are NAN.
You are watching: Can only use .str accessor with string values, which use np.object_ dtype in pandas
As the error states, you deserve to only use .str v string columns, and also you have actually a float64. There won"t be any type of commas in a float, for this reason what you have actually won"t really do anything, however in general, you could actors it first:
You can use series to deal with this error.
dc_listings<"price">.series.str.replace(",", "")And if series doesn"t work you can additionally alteratively usage apply(str) as shown below:
If price is a dtype to rise 64 climate the data is not a string.You can shot dc_listings<"price">.apply(function)
Thanks for contributing an answer to stack Overflow!Please be certain to answer the question. Carry out details and share her research!
But avoid …Asking because that help, clarification, or responding to other answers.Making statements based upon opinion; back them increase with referrals or an individual experience.
To find out more, see our advice on writing great answers.
write-up Your answer Discard
Not the answer you're feather for? Browse other questions tagged python pandas or questioning your very own question.
Locating details numbers in obelisk rows for instance 123456789 in pillar Pan if i want to locat rows that contain 1234
AttributeError: deserve to only usage .str accessor v string values, which use np.object_ dtype in pandas (Python)
See more: Two Strangers In The Bright Light S Lyrics, Wish I Knew You
site architecture / logo © 2021 ridge Exchange Inc; user contributions license is granted under cc by-sa. Rev2021.11.10.40696