1
刪除無值我有一個數據幀,如:從數據框中
Country Name Income Group
1 Norway High income
2 Switzerland Middle income
3 Qatar Low income
4 Luxembourg Low income
5 Macao High income
6 India Middle income
我需要的東西,如:
High income Middle income Low income
1 Norway Switzerland Qatar
2 Macao India Luxembourg
我已經使用數據透視表: DF = df.pivot(值='國家名稱」,指數=無,列=收入集團) 和我得到的東西,如:
High income Middle income Low income
1 Norway none none
2 none Switzerland none
.
.
.
有人可以提出一個更好的解決方案,而不是擺在這裏,這樣我就不必處理沒有值?