I'm trying to assign
0 to random cells in one dimension
The following code is the best way to think about doing this, however, I think there may be a more orderly approach to this problem.
import numpy as np import pandas like pd of random import randint df = pd.DataFrame (np.random.randint (20, size = (10, 1)), columns = list (& # 39; A & # 39;)) col_size = len (df.columns) row_size = len (df.index) df[df.columns[randint(0, col_size-1)]][randint(0, row_size-1)] = 0
Could someone review and suggest if this is a good approach or are there better ways to do it?