How to convert a Scikit-learn dataset to a Pandas dataset?

后端 未结 22 2175
清酒与你
清酒与你 2020-11-28 19:10

How do I convert data from a Scikit-learn Bunch object to a Pandas DataFrame?

from sklearn.datasets import load_iris
import pandas as pd
data = load_iris()
p         


        
22条回答
  •  情话喂你
    2020-11-28 19:33

    Here's another integrated method example maybe helpful.

    from sklearn.datasets import load_iris
    iris_X, iris_y = load_iris(return_X_y=True, as_frame=True)
    type(iris_X), type(iris_y)
    

    The data iris_X are imported as pandas DataFrame and the target iris_y are imported as pandas Series.

提交回复
热议问题