我想追加一個空行在數據幀的末尾,但無法這樣做,甚至試圖瞭解大熊貓如何使用附加功能,仍然沒有得到它。使用熊貓追加數據框中的空行
下面的代碼:
import pandas as pd
excel_names = ["ARMANI+EMPORIO+AR0143-book.xlsx"]
excels = [pd.ExcelFile(name) for name in excel_names]
frames = [x.parse(x.sheet_names[0], header=None,index_col=None).dropna(how='all') for x in excels]
for f in frames:
f.append(0, float('NaN'))
f.append(2, float('NaN'))
有兩列和行的隨機數。
與「打印F」爲循環我得到這個:
0 1
0 Brand Name Emporio Armani
2 Model number AR0143
4 Part Number AR0143
6 Item Shape Rectangular
8 Dial Window Material Type Mineral
10 Display Type Analogue
12 Clasp Type Buckle
14 Case Material Stainless steel
16 Case Diameter 31 millimetres
18 Band Material Leather
20 Band Length Women's Standard
22 Band Colour Black
24 Dial Colour Black
26 Special Features second-hand
28 Movement Quartz
你能解釋一下代碼嗎?它很難衡量你想要追加什麼 - 行,列或數據框? – user3667569
@ user3667569我在xlsx中有多行和2列的數據,我需要在最後添加一個空行。 for循環只是我嘗試不用的運氣。 –