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

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

    This snippet is only syntactic sugar built upon what TomDLT and rolyat have already contributed and explained. The only differences would be that load_iris will return a tuple instead of a dictionary and the columns names are enumerated.

    df = pd.DataFrame(np.c_[load_iris(return_X_y=True)])
    

提交回复
热议问题