我csv
文件看起來像:CSV文件給出的字符串
"(-0.16192019, -0.007456851, 0.08841695)","(-0.10439591, 0.024501082, 0.12783173)","(-0.05965481, 0.049002163, 0.12144014)",...
,但我不希望引號。
我寫的功能爲:
for j in range(len(sensor_data)):
with open(names[j] + "P" + str(i) + ".csv", "wb") as f:
writer = csv.writer(f)
writer.writerows(sensor_data[j])
我sensor_data[j]
是這樣的:
gyro.append((float(merge.iloc[j, 2]), float(merge.iloc[j, 3]), float(merge.iloc[j, 4]))) if merge.iloc[j, 0] == 'Gyroscope' \
else acc.append((float(merge.iloc[j, 2]), float(merge.iloc[j, 3]), float(merge.iloc[j, 4])))
爲什麼沒有打印出花車,而不是字符串的元組的元組?
merge = pd.read_csv(final_user_study_path + "/P" + str(i) + "/DataCollection/data/merge.csv")
合併的樣子:
Gyroscope,50958,-0.3387541,0.014913702,0.05965481
Gyroscope,50978,-0.23009712,0.03621899,0.044741105
LinearAcceleration,50979,-0.09891046,0.119261175,-0.108936176
Gyroscope,50998,-0.1768339,0.066046394,0.040480047
LinearAcceleration,50999,-0.0863409,0.18240824,-0.07152677
類型所有這些值都是字符串。
我想:
(-0.16192019, -0.007456851, 0.08841695),(-0.10439591, 0.024501082, 0.12783173),(-0.05965481, 0.049002163, 0.12144014),...
其中'merge'定義了嗎? –
已編輯的問題陳述 – dirtysocks45
編輯問題陳述 – dirtysocks45