I am new to pandas. I am trying to assign a negative sign to one of the column in data frame with below code. but while i do that i get error as below. I tried with below code
INTERNAL_DEBIT = InternalTxns[InternalTxns['type'].isin(['INTERNAL_DEBIT','INTERNAL'])]
new_amnt = (INTERNAL_DEBIT['amount']*-1)
but i need to assign this negative value to only matching conditions and get entire data. I am looking for simpler and less coding.
I read through other posts for the similar error but most of them are not for similar requirement.
Thanks in advance.
InternalTxns[[InternalTxns["type"] in ["INTERNAL_DEBIT","INTERNAL_TRANSFER_REVERSAL"]],'amount']=InternalTxns[[InternalTxns["type"] in ["INTERNAL_DEBIT","INTERNAL_TRANSFER_REVERSAL"]],'amount']*-1
InternalTxns.loc[InternalTxns["type"].isin(["INTERNAL_DEBIT","INTERNAL_TRANSFER_REVERSAL"]),'amount']=InternalTxns['amount']*-1
– EdChumInternalTxns.loc[InternalTxns["type"].isin(["INTERNAL_DEBIT","INTERNAL_TRANSFER_REVERSAL"]),'amount'] *= -1
Also on SO it's common form to post raw data or a link to your data plus your code and desired output rather than images – EdChum