如何将新元素'NEW'
添加到numpy数组features
?
df = pd.DataFrame(df_scaled)
df['NEW'] = minutes
features = np.append(features, 'NEW', 1)
df.to_excel("A.xls", header=features[sorted_idx],index=False)
错误:
ValueError: all the input arrays must have same number of dimensions
答案 0 :(得分:0)
我假设features
是一维字符串数组。然后你可以这样做:
features =np.append(features,['New'])
但是如果您只想将DataFrame的标题作为数组,则可能更好:
features = df.columns.values