python - 有没有办法删除一列来执行 TSNE?

标签 python

我正在使用 KNN 对 IMDb 和 Youtube 电影预告片进行分类。 因为它有很多维度,所以我决定使用 TSNE。 但是,不断出现错误,提示:无法将字符串转换为 float :'Avatar'

这是我的代码。

import matplotlib.pyplot as plt
from sklearn.manifold import TSNE
model = TSNE(learning_rate=100)
transformed = model.fit_transform(df2)

xs = transformed[:,0]
ys = transformed[:,1]
plt.scatter(xs,ys,c=labels)

我认为我应该简单地删除“movie_title”列,这样我就只剩下 TSNE 的数字数据。有没有办法删除数据集中的特定列?

我的数据集列是:movie_titlegenrescountryrange总金额预算imdb_score观看次数评分

我已经尝试过 - table.Columns.Remove("movie_title"),但这似乎不起作用......

感谢您的阅读!

最佳答案

您可以使用df.drop() 。如果您的 DataFrame 名为 table,请使用:

table.drop('movie_title', axis=1, inplace=True)

关于python - 有没有办法删除一列来执行 TSNE?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59242235/

相关文章:

c# - 在不写入文件的情况下在 Python 和 C# 之间传递数据

python - 使用 python 读取 github 文件返回 HTML 标签

python - 无法在 AWS Rest API 请求中使用 "Filter"

python - 如何在 PyQt4 QTreeWidget 的列单元格内绘制烛台条

python - 从 BaseHTTPServer 解析 Python HTML POST 数据

python Fabric : How to handle arbitrary remote shell prompt for input?

python - 非线性函数的 numpy 爱因斯坦求和

python - 我应该使用什么版本的 Python 来开发 Web 应用程序?

python - sys.stdout.writelines ("hello")和 sys.stdout.write ("hello")

python - 将 Excel 工作簿拆分为多个 Excel 文件