Skip to content

Commit 597552c

Browse files
author
minjk-bl
committed
Fix data sampling code to prevent error on index issue
1 parent 9e2b402 commit 597552c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

visualpython/python/variableCommand.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,16 @@ def _vp_sample(data, sample_cnt):
102102
"""
103103
Sampling data
104104
"""
105-
dataType = type(data).__name__
105+
data_type = type(data).__name__
106106
sample_cnt = len(data) if len(data) < sample_cnt else sample_cnt
107107

108-
if dataType == 'DataFrame':
108+
if data_type == 'DataFrame':
109109
return data.sample(sample_cnt, random_state=0)
110-
elif dataType == 'Series':
111-
return data.sample(sample_cnt, random_state=0)
112-
elif dataType == 'ndarray':
110+
elif data_type == 'Series':
111+
return data.sample(sample_cnt, random_state=0).reset_index(drop=True)
112+
elif data_type == 'ndarray':
113113
return data[_vp_np.random.choice(data.shape[0], sample_cnt, replace=False)]
114-
elif dataType == 'list':
114+
elif data_type == 'list':
115115
return _vp_rd.choices(data, k=sample_cnt)
116116
return data
117117

0 commit comments

Comments
 (0)