Sklearn preprocessing - PolynomialFeatures - How to keep column names/headers of the output array / dataframe
<p>TLDR: <strong>How to get headers for the output numpy array from the sklearn.preprocessing.PolynomialFeatures() function?</strong> </p>

<hr>

<p>Let's say I have the following code...</p>

<pre><code>import pandas as pd
import numpy as np
from sklearn import preprocessing as pp

a = np.ones(3)
b = np.ones(3) * 2
c = np.ones(3) * 3

input_df = pd.DataFrame([a,b,c])
input_df = input_df.T
input_df.columns=['a', 'b', 'c']

input_df

    a   b   c
0   1   2   3
1   1   2   3
2   1   2   3

poly = pp.PolynomialFeatures(2)
output_nparray = poly.fit_transform(input_df)
print output_nparray

[[ 1.  1.  2.  3.  1.  2.  3.  4.  6.  9.]
 [ 1.  1.  2.  3.  1.  2.  3.  4.  6.  9.]
 [ 1.  1.  2.  3.  1.  2.  3.  4.  6.  9.]]
</code></pre>

<p>How can I get that 3x10 matrix/ output_nparray to carry over the a,b,c labels how they relate to the data above? </p>