Skip to content
Advertisement

shape error while concating columns after Principal Analysis in csv

I am applying PCA in my csv data. After normalization, seems PCA is working. I want to plot projection by making 4 components. but I am stuck with this error :

JavaScript

This is my code:

JavaScript

I guess I am getting error while concat my components and df[‘type’].

Can I get idea to get rid of this error?

Thank you.

Advertisement

Answer

The index in df is not the same as in principalDf. We have (using a short version of your data)

JavaScript

and

JavaScript

Hence concat is getting confused. You can fix this by resetting the index early on:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement