• Register
0 votes
860 views

Problem :

I am getting bellow error
attributeerror: can only use .str accessor with string values, which use np.object_ dtype in pandas
6.9k points

1 Answer

0 votes

Solution :

As the problem statement states that you can only use .str with string columns but you have a float64. So there should not be any commas in a float so what you have will not really do anything, but you could cast it first:

dc_listings['price'].astype(str).str.replace...

For example:

In [18]: df
Out[18]:
          a         b         c         d         e
0  0.645821  0.152197  0.006956  0.600317  0.239679
1  0.865723  0.176842  0.226092  0.416990  0.290406
2  0.046243  0.931584  0.020109  0.374653  0.631048
3  0.544111  0.967388  0.526613  0.794931  0.066736
4  0.528742  0.670885  0.998077  0.293623  0.351879
36.1k points

Related questions

0 votes
0 answers 23 views
23 views
import cv2, time, pandas import numpy as np from termcolor import colored import datetime import pandas as pd import matplotlib.pyplot as plt import os import pyautogui from bokeh.plotting import figure, show, output_file from bokeh.models import HoverTool, ColumnDataSource first_frame = None ... ).strftime("%Y-%m-%d_%H%M%S")+".html") show(p) #plt.savefig('plot.pdf', dpi=300, bbox_inches='tight')
asked Jun 13 Shivi Trivedi
2 votes
1 answer 679 views
679 views
Problem : I am very new to Python and Pandas. Currently I am learning to use the Pandas so that I can convert my column to month. When I try to read my data then they are objects. So I am first of all trying to make them to the date time and ... " 2529 "values") 2530 AttributeError: Can only use .dt accessor with datetimelike values Looking for help from Pandas expert to fix my above error.
asked Apr 29 stewart 4k points
0 votes
1 answer 2.1K views
2.1K views
Problem : I have the pandas data frame with some of the categorical predictors or variables as 0 & 1, and some of the numeric variables. When I fit that to a stasmodel like below : est = sm.OLS(y, X).fit() It throws the below error : Pandas data ... hundreds of variables. For that I have concatenated the 3 pandas DataFrames to come up with the final DataFrame to be used in the model building.
asked Dec 18, 2019 alecxe 7.5k points
0 votes
1 answer 898 views
898 views
Problem : I have the two DataFrames which I would want to merge. I have referred many documents and also tried to perform many operations but I am not sure what to do now. Please find my two DataFrames as below: DataFrame1: id name type currency 0 BTTA.S Apple ... here I met with the exception as below : ValueError: can not merge DataFrame with instance of type <class 'pandas.core.series.Series'>
asked Dec 24, 2019 alecxe 7.5k points
0 votes
1 answer 1.7K views
1.7K views
Problem : I have a big dataframe and I am trying to split that and after concat that but facing following error first argument must be an iterable of pandas objects, you passed an object of type "dataframe"
asked Nov 14, 2019 peterlaw 6.9k points