我有一个17520行1,000列的numpy.ndarray。np.ndarray只有两个值[0,0.05]。我想修改值为0.05的单元格,以便在0和0.05之间随机选择。为了做到这一点,我使用了post Random choice over specific values of a DF推荐的以下函数 import pandas as pd
df = pd.DataFramesize=df.shape), filter_func=lambda x: x==0.05)
我有一个叫做'population‘的数据框架,看起来像这样-0 Mumbai 100000npop = len(population) #number of popuation centres
for i in np.arangei]['Name'][0]['Susceptible'] = population.iloc[i