首页 > 解决方案 > 如何在 .txt 文件中使用 Pandas 的 Parallel_coordinates

问题描述

我正在尝试在 .txt 文件上使用 pandas 的 parallel_coordinates,但我有两个问题:

import pandas as pd
from pandas import read_fwf
from pandas.tools.plotting import parallel_coordinates
from matplotlib import pyplot as plt
df= pd.read_fwf(rPathtoFile)
parallel_coordinates(df, "GTID")
plt.show()

1)使用此代码,我得到 KeyError: "GTID" 即使 GTID 是我的 .txt 文件中包含该类的列的名称。(抱歉,我无法共享更多文件)。我的数据框已成功加载,我检查了正在使用的 df.head() .txt 文件

2)我只想绘制第 4、14、15 列:有没有办法做到这一点?

标签: pythonpandasparallel-coordinates

解决方案


推荐阅读