pandas常用代碼模塊
Pandas提取Excel中唯一值的最后數值保存
import pandas as pd # 假設數據保存在Excel文件中,加載數據 df = pd.read_excel(r'C:\\Users\\Administrator\\Desktop\\物料收發明細表_2024011709475312_230690_part1.xlsx') # 根據唯一值取最后出現的數值 df['Last_Value'] = df.groupby('唯一值')['(結存)數量(庫存)'].transform('last') # 將結果保存到新的Excel文件 df.to_excel('output_excel_file.xlsx', index=False)

浙公網安備 33010602011771號