<h4 dir="auto">Problem description</h4>
<p dir="auto">There are several convenient datasets available in <code class="notranslate">sklearn</code>.  They consistently return the <a href="https://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_breast_cancer.html#sklearn.datasets.load_breast_cancer" rel="nofollow"><code class="notranslate">Bunch</code></a> <code class="notranslate">sklearn</code> object. Therefore, it would not be too difficult to create a function to convert from <code class="notranslate">sklearn</code> into a nice, clean <code class="notranslate">pandas</code> dataframe.</p>
<h4 dir="auto">Proposal</h4>
<p dir="auto">I am happy to take on the task of creating this conversion, but I'd like to get some input so that I create what users would actually want, and ideally my pull request would be accepted.</p>
<p dir="auto">Below is a toy example of how I would expect the API to work, where <code class="notranslate">to_dataframe</code> is the name of the new method. (I'm happy to call it whatever, that just seemed like a good guess.)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; from sklearn.datasets import load_iris
&gt;&gt;&gt; sk_iris = load_iris()
&gt;&gt;&gt; pd_iris = sk_iris.to_dataframe()
&gt;&gt;&gt; pd_iris.head()

   sepal length (cm)  sepal width (cm)  petal length (cm)  petal width (cm)  target
0                5.1               3.5                1.4               0.2     setosa
1                4.9               3.0                1.4               0.2     setosa
2                4.7               3.2                1.3               0.2     setosa
3                4.6               3.1                1.5               0.2     setosa
4                5.0               3.6                1.4               0.2     setosa

&gt;&gt;&gt; pd_iris.dtypes
sepal length (cm)     float64
sepal width (cm)      float64
petal length (cm)     float64
petal width (cm)      float64
target                category
dtype: object

&gt;&gt;&gt; type(pd_iris)
&lt;class 'pandas.core.frame.DataFrame'&gt;"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; from sklearn.datasets import load_iris
&gt;&gt;&gt; sk_iris = load_iris()
&gt;&gt;&gt; pd_iris = sk_iris.to_dataframe()
&gt;&gt;&gt; pd_iris.head()

   sepal length (cm)  sepal width (cm)  petal length (cm)  petal width (cm)  target
0                5.1               3.5                1.4               0.2     setosa
1                4.9               3.0                1.4               0.2     setosa
2                4.7               3.2                1.3               0.2     setosa
3                4.6               3.1                1.5               0.2     setosa
4                5.0               3.6                1.4               0.2     setosa

&gt;&gt;&gt; pd_iris.dtypes
sepal length (cm)     float64
sepal width (cm)      float64
petal length (cm)     float64
petal width (cm)      float64
target                category
dtype: object

&gt;&gt;&gt; type(pd_iris)
&lt;class 'pandas.core.frame.DataFrame'&gt;
</code></pre></div>
<p dir="auto">Would this be desirable?  Is this API I propose reasonable?  What should I consider in the API?  (E.g., in the example above, I have taken the fact that the <code class="notranslate">sklearn</code> dataset object has both a <code class="notranslate">target</code> and <code class="notranslate">target_names</code>, which means that I could infer that this should be a categorical. This can obviously make things a bit more fragile. Should this inference be skipped?</p>
<p dir="auto">Users should be able to get datasets returned as [Sparse]DataFrames with named columns in this day and age, for those datasets otherwise providing a Bunch with <code class="notranslate">feature_names</code>. This would be controlled with an <code class="notranslate">as_frame</code> parameter (though <code class="notranslate">return_X_y='frame'</code> would mean the common usage is more succinct).</p>