Skip to content

Commit e2a3b12

Browse files
StrikerRUSguolinke
authored andcommitted
added check for pandas DataFrame dimentions (#1402)
1 parent af40156 commit e2a3b12

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Diff for: python-package/lightgbm/basic.py

+2
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ def c_int_array(data):
239239

240240
def _data_from_pandas(data, feature_name, categorical_feature, pandas_categorical):
241241
if isinstance(data, DataFrame):
242+
if len(data.shape) != 2 or data.shape[0] < 1:
243+
raise ValueError('Input data must be 2 dimensional and non empty.')
242244
if feature_name == 'auto' or feature_name is None:
243245
data = data.rename(columns=str)
244246
cat_cols = data.select_dtypes(include=['category']).columns

0 commit comments

Comments
 (0)