python - importing array into pandas but losing a column -
python - importing array into pandas but losing a column -
import numpy np import pandas pd import sklearn sklearn.datasets import load_boston boston1 = load_boston() boston2 = pd.dataframe(boston.data, columns = boston.feature_names[0:13]) boston2.keys()
the medv column disappears? please help driving me crazy , don't know doing wrong
import numpy np import pandas pd import sklearn import sklearn.datasets ds boston1 = ds.load_boston() boston2 = pd.dataframe( np.column_stack([boston1.data, boston1.target]), columns = boston1.feature_names) print(boston2.keys())
yields
index([u'crim', u'zn', u'indus', u'chas', u'nox', u'rm', u'age', u'dis', u'rad', u'tax', u'ptratio', u'b', u'lstat', u'medv'], dtype='object')
print(boston1.descr)
gives mysterious comment, "median value (attribute 14) target". not mention how access medv data.
the code on page shows way: boston1.target
medv. found page googling "boston medv target".
python pandas scikit-learn
Comments
Post a Comment