How to retain column headers of data frame after Pre-processing in scikit-learn

后端 未结 4 1718
耶瑟儿~
耶瑟儿~ 2020-12-13 12:52

I have a pandas data frame which has some rows and columns. Each column has a header. Now as long as I keep doing data manipulation operations in pandas, my variable headers

4条回答
  •  不思量自难忘°
    2020-12-13 13:18

    The above answers still do not resolve the main question. There are two implicit assumptions here

    1. That all the features of the dataset will be retained which might not be true. E.g. some kind of feature selection function.
    2. That all the features will be retained in the same order, again there might be implicit sorting in some feature selection transformations.

    There is a "get_support()" method in at least some of the fit and transform functions that save the information on which columns(features) are retained and in what order.

    You can check the basics of the function and how to use it here ... Find get_support() function description here

    This would be the most preferred and official way to get the information needed here.

提交回复
热议问题