Search code examples
pythonpandasfeature-engineering

What does these Pandas code says ?, pls explain it to in normal term?


I wanna understand this code in a feature engineering term

train['TransactionAmt_to_mean_card1'] = train['TransactionAmt'] / train.groupby(['card1'])['TransactionAmt'].transform('mean')

Solution

  • This function creates a new column that is the the “TransactionAmount” divided by the mean of the of the “TransactionAmount” for all the entries with the same value for “card1”.