From e2a3b1251b0454f903df31006a103715774f3f3c Mon Sep 17 00:00:00 2001 From: Nikita Titov Date: Tue, 29 May 2018 09:03:35 +0300 Subject: [PATCH] added check for pandas DataFrame dimentions (#1402) --- python-package/lightgbm/basic.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python-package/lightgbm/basic.py b/python-package/lightgbm/basic.py index ae9b821dd9aa..efef761a0072 100644 --- a/python-package/lightgbm/basic.py +++ b/python-package/lightgbm/basic.py @@ -239,6 +239,8 @@ def c_int_array(data): def _data_from_pandas(data, feature_name, categorical_feature, pandas_categorical): if isinstance(data, DataFrame): + if len(data.shape) != 2 or data.shape[0] < 1: + raise ValueError('Input data must be 2 dimensional and non empty.') if feature_name == 'auto' or feature_name is None: data = data.rename(columns=str) cat_cols = data.select_dtypes(include=['category']).columns