你好,我有數據集有幾千行,分爲偶數行和奇數行,我找不到在同一行再次將它們連接在一起的方法。讀取文件並覆蓋它很好,或者創建一個新文件。Python將數據線連接在一起
我發現這個example打印單獨的行,但無法將它寫入文件。
我想它是這樣的:數據集的
Time = 1 Temperature1 = 24.75 Temperature2 = 22.69 Temperature3 = 20.19 RPM = -60.00
Time = 2 Temperature1 = 24.75 Temperature2 = 22.75 Temperature3 = 20.19 RPM = -60.00
etc...
例子:
Time = 1 Temperature1 = 24.75 Temperature2 = 22.69 Temperature3 = 20.19
RPM = -60.00
Time = 2 Temperature1 = 24.75 Temperature2 = 22.75 Temperature3 = 20.19
RPM = -60.00
Time = 3 Temperature1 = 24.75 Temperature2 = 22.75 Temperature3 = 20.19
RPM = -60.00
Time = 4 Temperature1 = 24.81 Temperature2 = 22.81 Temperature3 = 20.25
RPM = -60.00
Time = 5 Temperature1 = 24.81 Temperature2 = 22.81 Temperature3 = 20.19
RPM = -60.00
Time = 6 Temperature1 = 24.81 Temperature2 = 22.81 Temperature3 = 20.19
RPM = -60.00
Time = 7 Temperature1 = 24.81 Temperature2 = 22.81 Temperature3 = 20.25
RPM = -60.00
Time = 8 Temperature1 = 24.81 Temperature2 = 22.87 Temperature3 = 20.25
RPM = -60.00
Time = 9 Temperature1 = 24.87 Temperature2 = 22.87 Temperature3 = 20.25
RPM = -60.00
Time = 10 Temperature1 = 24.87 Temperature2 = 22.87 Temperature3 = 20.25
RPM = -60.00
我建議使用熊貓數據幀。您可以輕鬆將其合併並保存到文件。 – user1877600
你能舉個例子嗎?是一種新的python,並不承認熊貓數據框,正在瀏覽其文檔,但不知道如何將其應用於我的問題。 –