Fix issue 2670 (#2671)

* fix issue 2670

* add python<3.6 compatibility

* fix Index

* fix Index/MultiIndex

* fix lint

* fix W0622

really nonsense

* fix lambda

* Trigger Travis

* add test for MultiIndex

* remove tailing whitespace
This commit is contained in:
Icyblade Dai
2017-09-20 03:49:41 +08:00
committed by Yuan (Terry) Tang
parent ee80f348de
commit 0e85b30fdd
2 changed files with 24 additions and 1 deletions

View File

@@ -184,7 +184,13 @@ Did not expect the data types in fields """
raise ValueError(msg + ', '.join(bad_fields))
if feature_names is None:
feature_names = data.columns.format()
if hasattr(data.columns, 'to_frame'): # MultiIndex
feature_names = [
' '.join(map(str, i))
for i in data.columns
]
else:
feature_names = data.columns.format()
if feature_types is None:
feature_types = [PANDAS_DTYPE_MAPPER[dtype.name] for dtype in data_dtypes]