将索引更改为从数据框的第二行开始。因为,这个数据帧将被转换为Ordereddict,我将使用元素的第一行作为我的数据集的标签。
- 在数据帧中进行多索引,但是当我改为ordereddict时,dict有两个键:
OrderedDict([('0','shot')0 1577 1 1577])
我只想要一个键,剩下的就是值,但是'shot'不应该被索引,因为这将是数据的列名
目前有序的指令看起来像这样:OrderedDict([('0',0 shot 1 1577 2 1577 3 2106 4 2106 5 1875)]我想这样:
OrderedDict([('0',shot 0 1577 1 1577 2 2106 3 2106 4 1875)]
你可以像下面的代码那样做:
data = np.loadtxt("path to file", delimiter = ',', dtype = 'str')
csv_data = data[1:,0:2] #[start row:end row, start col:end col]
告诉我这是否有助于解决您的问题?