csv python中的多个列表,带有np.savetxt



我尝试检测有色对象的方向。我提取了颜色和强度曲线。颜色=标量int_prof = [11,...,11]

我想现在保存多个列表,并将相应的颜色值保存到一个CSV中。

现在每个列表都应是一列,颜色val应该转换为字符串,并应命名我的列。因此,我使用pandas dataframe编写了一种方法。

错误:参考文章正确保存在列表中但是在CSV中,我会增加数量。有人可以给我一个提示,错误隐藏了吗? data = {}

def saveReferences(self,referenceLines,center,container):
    print(referenceLines)
    for i in range(len(container.colors)):
        self.data.update({str(container.colors[i]):referenceLines[i]})
    df = pd.DataFrame(self.data)   
    df.to_csv("foo.csv")
    print("Save References")
>     def saveReferences(self,referenceLines,center,container):
        print(self.referenceProfiles)
        for i in range(len(self.colors)):
            print("saving:",i)
            for num in range(container.saftyFaktor):
                self.data.update({"Color_"+str(self.colors[i])+"_Number_"+str(num):self.referenceProfiles[i+num]})
        df = pd.DataFrame(self.data)   
        df.to_csv("foo.csv",";")
        print(self.data)
        print("Save References")
The code solves the problem!

最新更新