python - Numpy and Matplotlib - AttributeError: 'numpy.ndarray' object has no attribute 'replace' - Stack Overflow
Medical Data Visualizer AttributeError: 'numpy.ndarray' object has no attribute
python - AttributeError: 'numpy.ndarray' object has no attribute 'nan_to_num' - Data Science Stack Exchange
'numpy.float64' object has no attribute 'replace'
Videos
Hallo Everyone,
I hope you are all fine, I have this code which I am getting error from , I run the same code on my Spyder and I do not get any error but when I run it on Jupyter Notebook I get this error :
'numpy.float64' object has no attribute 'replace'
this is the code that I have :
oli_row2 = df_oli.iloc[2].tolist()
idx = oli_row2.index("DB")
check_words = oli_row2[idx:]
exact_order = ['NN','ch','ab','An','tr','bcc',]
for i in range(len(check_words)):
if not(check_words[i].replace(" ","")==exact_order[i].replace(" ","")):
new_row = table.add_row()
new_row.cells[0].text = 'Oli'
new_row.cells[1].text = 'Words are out of order in Column'
new_row.cells[2].text = str(check_words[idx])
oli_flag = True
print('Out of order')
I googled lit bit but I could not find any solution.
Thank you in advance,
Best Regards,
Hi,
I'm trying to create a numpy v-stack and creating 3 np.array's for it, by filling them with a loop:
I get the error: 'AttributeError: 'numpy.ndarray' object has no attribute 'np' . I think I'm using the wrong notation to append to the empty arrays:
neighbor_id = [id_ for id_ in range(1, n_obs) if id_ != user_id]
neighbor_id_arr = np.array(neighbor_id)
similarity = np.array([])
num_interactions = np.array([])
# get similarity and num_interactions
for id_ in neighbor_id:
similarity.np.append(np.dot(user_item.loc[user_id],user_item.loc[id_])) #The issue is here, I think
num_interactions.np.append(user_interactions.loc[id_])
c = numpy.vstack((neighbor_id_arr, similarity,num_interactions))
Thanks!
James
It would be helpful if you could post the full stack trace, so that we can see which line your error occurs at. In general, the more information you can provide in a question, the better.
In this case, it looks like your full_model_pipeline may somehow become a numpy array. Since you have a one-element pipeline, you could try changing
full_model_pipeline = Pipeline(steps =[
('full_pipeline',full_pipeline),
('model',LinearRegression())
])
full_model_pipeline.fit(X_train,y_train)
to
model = LinearRegression()
model.fit(X_train, y_train)
I believe you need to add () where you add scaler to the pipeline: ('std_scaler',StandardScaler) --> ('std_scaler',StandardScaler())