A Complete Tutorial to Learn Data Science with Python from Scratch



So when creating pivot table using python, you have used values=‘Loan_Status’ to grant loan based on the credit history. Will this create a new column and if yes. I am having problem with it because it sending the following error message.
Traceback (most recent call last):
File “”, line 13, in
File “C:\Users\Raghav\PycharmProjects\loan\venv\lib\site-packages\pandas\core\frame.py”, line 5303, in pivot_table
File “C:\Users\Raghav\PycharmProjects\loan\venv\lib\site-packages\pandas\core\reshape\pivot.py”, line 61, in pivot_table
raise KeyError(i)
KeyError: ‘LoanStatus’

Please help.
Thank you.


HI @raghav47,

It will not create a new column, it will create a pivot table between Loan_Status and Credit_History.

Please check that you have given the correct name for the column Loan_Status. It should match with the name of the column in your data.


there is no column named Loan_Status in the csv file.


The target variable is loan status, so the column should be present in the train.csv file