1
我有一個很大的.csv文件,我正在閱讀熊貓數據框。然後我遍歷該文件,一旦找到我正在查找的值,我使用dataR = df.append(data)。 .csv文件中有2列,我讀取(列A)中的值從1到3,然後再次從1到3再次重複,如下所示:請注意,B列不重複。熊貓數據幀在循環中
+-----+---+---+--+--+
| | A | B | | |
+-----+---+---+--+--+
| 288 | 1 | 4 | | |
+-----+---+---+--+--+
| 245 | 2 | 3 | | |
+-----+---+---+--+--+
| 543 | 3 | 6 | | |
+-----+---+---+--+--+
| 867 | 1 | 9 | | |
+-----+---+---+--+--+
| 345 | 2 | 7 | | |
+-----+---+---+--+--+
| 122 | 3 | 8 | | |
+-----+---+---+--+--+
| 233 | 1 | 1 | | |
+-----+---+---+--+--+
| 346 | 2 | 6 | | |
+-----+---+---+--+--+
| 765 | 3 | 3 | | |
+-----+---+---+--+--+
我想要做的是什麼,而不是附加的價值爲行,我想追加他們爲這樣的列:
+-----+---+---+-----+
| | A | B | C |
+-----+---+---+-----+
| 288 | 1 | 4 | 9 |
+-----+---+---+-----+
| 245 | 2 | 3 | 7 |
+-----+---+---+-----+
| 543 | 3 | 6 | 8 |
+-----+---+---+-----+
| 867 |NaN| 9 | 1 |
+-----+---+---+-----+
| 345 |NaN| 7 | 6 |
+-----+---+---+-----+
| 122 |NAN| 8 | 3 |
+-----+---+---+-----+
| 233 |NaN| 1 | NaN |
+-----+---+---+-----+
| 346 |NaN| 6 | NaN |
+-----+---+---+-----+
| 765 |NaN| 3 | NaN |
+-----+---+---+-----+
有一個標誌,這個設置? DATAR = df.append(數據,標誌=?)
由於
這個問題可以通過[Minimal,Complete,and Verifiable](http://stackoverflow.com/help/mcve)示例來獲得幫助。這使我們更容易幫助你。 –