[rllib] "AttributeError: 'numpy.ndarray' object has no attribute 'items'" on certain turn-based MultiAgentEnvs with Dict obs space.
Numpy.ndarray' object has no attribute 'head'
scikit learn - AttributeError: 'numpy.ndarray' object has no attribute 'columns' - Data Science Stack Exchange
AttributeError: 'numpy.ndarray' object has no attribute 'columns'
The problem is that train_test_split(X, y, ...) returns numpy arrays and not pandas dataframes. Numpy arrays have no attribute named columns
If you want to see what features SelectFromModel kept, you need to substitute X_train (which is a numpy.array) with X which is a pandas.DataFrame.
selected_feat= X.columns[(sel.get_support())]
This will return a list of the columns kept by the feature selector.
If you wanted to see how many features were kept you can just run this:
sel.get_support().sum() # by default this will count 'True' as 1 and 'False' as 0
because this :
X = df.iloc[:,:24481].values
y = df.iloc[:, -1].values
you should remove .values or make extra X_col, y_col like that
X_col = df.iloc[:,:24481]
y_col = df.iloc[:, -1]
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
Write a function to calculate accumulated GPA (omit grade <5).
def gpa_of_pass(marks, credits):
gpa_list=[]
for i in range(len(marks)):
for j in range(len(marks[i])):
if marks[i][j] < 5:
marks=marks[i].pop(j)
for i in marks:
for j in i:
gpa_list.append(np.dot(i,credits)/sum(credits))
return gpa_list
marks = np.array([
[8.0, 9.0, 10.0],
[4.0, 9.0, 8.0],
[8.0, 3.0, 8.0],
[10.0, 9.0, 5.0],
[9.0, 9.0, 4.0]
])
credits = np.array([2, 2, 1])
gpa_of_pass(marks, credits)I ran a for loop to remove the grade <5 before calculating the GPA but I got the error in the title. Would you please have any suggestions? Thank you so much!