Python 如何使用范围内的随机值向dataframe添加新行

Python 如何使用范围内的随机值向dataframe添加新行,python,pandas,numpy,dataframe,Python,Pandas,Numpy,Dataframe,我有一个数据框,我想添加更多的行,但我想添加非常具体的值。我需要在最大值和最小值的范围内添加值,例如: import pandas as pd import numpy as np d = {'col1': [1, 2, 10, 1, 2, 6, 7], 'col2': [3, 4, 4, 8, 4, 3, 2]} df = pd.DataFrame(data=d) 对于上面给定的数据帧,假设最大行值为10,9,最小值为1,0。我想在我的数据框中添加

我有一个数据框,我想添加更多的行,但我想添加非常具体的值。我需要在最大值和最小值的范围内添加值,例如:

    import pandas as pd
    import numpy as np
    
        d = {'col1': [1, 2, 10, 1, 2, 6, 7], 'col2': [3, 4, 4, 8, 4, 3, 2]}

df = pd.DataFrame(data=d)
对于上面给定的数据帧,假设最大行值为10,9,最小值为1,0。我想在我的数据框中添加100行,其中随机值介于最高值行和最低值行之间

我想根据最大行值和最小行值的范围生成值

adf = pd.DataFrame( {
    'col1': np.random.randint(1,10,100), 
    'col2': np.random.randint(0,9,100)  })
要添加浮动值,请执行以下操作:

adf = pd.DataFrame( {
    'col1': np.random.uniform(1,10,100), 
    'col2': np.random.uniform(0,9,100)  })
将现有df添加为新列的步骤

df['col3'] = np.random.randint(1,10,len(df))