我有点困惑,因为以下几点似乎有用:
raw_data_df = pd.DataFrame()
temp = pd.read_csv('/Users/bob/desktop/Research_data/tobii/42r-export.csv', sep = ',', encoding = 'latin-1')
raw_data_df['1'] = temp['Gaze point X']
raw_data_df['2'] = temp['Gaze point Y']
但是,以下操作不起作用:
^{pr2}$文件在哪里
path = "/Users/bob/desktop/Research_data/tobii/"
files = [f for f in listdir(path) if isfile(join(path,f))]
我得到了一个列表列表,而不是返回列名称为i+“x”或i+“y”的pandas数据框。在
下面是一个用原始数据输出的示例
132660 857
132661 846
Name: Gaze point X, Length: 132662, dtype: int64
0 1206
1 1204
2 1205
3 1205
如何将多个csv文件的选定列连接到一个数据帧中?在
抱歉有个直营店我正在搜索的文件里面的文件把所有的东西都翻出来了。我刚刚删除了它,它正在工作。在
我不认为有任何必要初始化一个空的数据帧。您可以迭代文件,只加载所需的列(使用
usecols
),然后在末尾连接所有数据帧。在此外,当连接路径工件时,使用
os.path.join
。在现在,只需用
^{pr2}$pd.concat
连接数据帧。在基于@COLDSPEED's solution,可以使用列表理解:
相关问题 更多 >
编程相关推荐