Der Code läuft einwandfrei, aber jedes Mal, wenn er ausgeführt wird, erhalte ich diese Veraltungsmeldung:
Code: Select all
DeprecationWarning: DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated, and in a future version of pandas the grouping columns will be excluded from the operation. Either pass `include_groups=False` to exclude the groupings or explicitly select the grouping columns after groupby to silence this warning.
Code: Select all
fprice = df.groupby(['StartDate', 'Commodity', 'DealType']).apply(lambda group: -(group['MTMValue'].sum() - (group['FixedPriceStrike'] * group['Quantity']).sum()) / group['Quantity'].sum()).reset_index(name='FloatPrice')
Hier sind einige Beispieldaten, die dieser Code verwendet:
Code: Select all
TradeID TradeDate Commodity StartDate ExpiryDate FixedPrice Quantity MTMValue
-------- ---------- --------- --------- ---------- ---------- -------- ---------
aaa 01/01/2024 (com1,com2) 01/01/2024 01/01/2024 10 10 100.00
bbb 01/01/2024 (com1,com2) 01/01/2024 01/01/2024 10 10 100.00
ccc 01/01/2024 (com1,com2) 01/01/2024 01/01/2024 10 10 100.00
Code: Select all
TradeID TradeDate Commodity StartDate ExpiryDate FixedPrice Quantity MTMValue FloatPrice
-------- ---------- --------- --------- ---------- ---------- -------- --------- ----------
aaa 01/01/2024 (com1,com2) 01/01/2024 01/01/2024 10 10 100.00 0
bbb 01/01/2024 (com1,com2) 01/01/2024 01/01/2024 10 10 100.00 0
ccc 01/01/2024 (com1,com2) 01/01/2024 01/01/2024 10 10 100.00 0
Mobile version