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