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

后端 未结 22 2070
清酒与你
清酒与你 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

    As of version 0.23, you can directly return a DataFrame using the as_frame argument. For example, loading the iris data set:

    from sklearn.datasets import load_iris
    iris = load_iris(as_frame=True)
    df = iris.data
    

    In my understanding using the provisionally release notes, this works for the breast_cancer, diabetes, digits, iris, linnerud, wine and california_houses data sets.

提交回复
热议问题