Add IDs to dataframe with random Noise

Solution 1:

You can build a new dataframe and concat them:

df1 = pd.concat([df['id'] + df['id'].max(),
                 df['time'] + df['time'].max(),
                 df['x'] + np.random.normal(0, 1, len(df)),
                 df['y'] + np.random.normal(0, 1, len(df))], axis=1) \
        .set_index(df.index + len(x))

out = pd.concat([df, df1])

Output:

>>> out
    id  time          x         y
0    1     1   1.000000  5.000000
1    1     2   2.000000  6.000000
2    1     3   3.000000  7.000000
3    1     4   4.000000  8.000000
4    2     5   9.000000  3.000000
5    2     6  11.000000  2.000000
10   3     7   1.479734  5.720535
11   3     8   0.076273  6.256060
12   3     9   2.856642  6.845974
13   3    10   4.119396  7.738969
14   4    11   9.220569  2.710783
15   4    12  10.451495  1.245976