![](/img/trans.png)
[英]How to print to only one column in an excel sheet using python panda
[英]How to add a empty column to a specific sheet in excel using panda?
我有一個包含 3 張工作表(PizzaHut、InAndOut、ColdStone)的 excel 文件。 我想在 InAndOut 表中添加一個空列。
path = 'C:\\testing\\test.xlsx'
data = pd.ExcelFile(path)
sheets = data.sheet_names
if 'InAndOut' in sheets:
something something add empty column called toppings to the sheet
data.to_excel('output.xlsx')
一直在環顧四周,但我找不到一個直觀的解決方案。
任何幫助將不勝感激!
sheet_name = 'InAndOut'
df = pd.read_excel(path, sheet_name)
# Do whatever
with pd.ExcelWriter(path, engine="openpyxl", mode="a", if_sheet_exists="replace") as writer:
df.to_excel(writer, sheet_name, index=False)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.