🛠️ Scheduled Maintenance | We’ll be undergoing scheduled maintenance and upgrades between 00:00 PST Jan 26th until 00:00 PST Jan 28th. There may be brief interruption of services in that period. We apologize for the inconvenience.

The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Anybody can ask a question
Anybody can answer
The best answers are voted up and moderated by our team

Credit Risk Modeling in Python Section PD Model 6.2

Credit Risk Modeling in Python Section PD Model 6.2


Hello, when importing the variables to build the PD Model, it returns me the following error pointing the problem to the line ·127 ‘mths_since_last_record:>86’]]”

KeyError: 'Passing list-likes to .loc or [] with any missing labels is no longer supported, see https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike'


4 Answers

365 Team

HI Edu,
Did you use the code provided in the lecture? 
If you made some changes, could you please share them with us?
The 365 Team

Hello 365 Team ,its been 7 months and no concrete information on this issue has been shared from your team. PLease ANSWER Volkmar question as everyone is facing same issue. I have also posted many questions but seems like 365 Team only cares about payment , once payment is done they are least bothered

2 months

I had the same problem, even when I copied and pasted the lecture code.
It turns out that using .loc[ ] with one or more missing labels is now deprecated (starting in version  The documentation (https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#indexing-deprecate-loc-reindex-listlike) suggests using .reindex() instead.
This worked for me:
inputs_train_with_ref_cat = loan_data_inputs_train.reindex([ list of column names ], axis=1)

Hello all,
I replaced .loc with .reindex and I get after
inputs_train = inputs_train_with_ref_cat.drop(ref_categories, axis = 1)
Many NaN:

grade:A                              0
grade:B                              0
grade:C                              0
grade:D                              0
grade:E                              0
... mths_since_last_record:3-20 373028 mths_since_last_record:21-31 373028 mths_since_last_record:32-80 373028 mths_since_last_record:81-86 373028 mths_since_last_record:>=86 373028 Length: 104, dtype: int64

It seems, that it doesn't work really with .reindex.

If I open the data loan_data_inputs_train.csv and all other, I do not find any NaN. All data are normal.

Any idea?

Best regard
Volkmar Meiller


Yes, I agree with Volkmar about retaining the indexes.
The best approach to this is using List comprehensions instead of Columns List . My solution can be found on the below link :
Hope it helps!