jeudi 17 juin 2021

How to change some values of a pandas df

I have created a pandas df using np.random.randn

data = np.random.randn(1, 10)

The output I am getting

[[-0.92408284 -2.61254901  0.95036968  0.81644508 -1.523876   -0.42804606
  -0.74240684 -0.7033438  -2.13962066 -0.62947496]]

Now, if I want to change 2/3 values extremely large or small (i.e 0.95036968 into 95.03 and -2.13962066 into -213.96) then what I have to do?

Here, I need the control to the number I want to change (2/3/4) and the changing bounds (say, +100 to -300) they can change any number randomly.

Expected Output:

[[-0.92408284 -2.61254901  95.03  0.81644508 -1.523876   -0.42804606
  -0.74240684 -0.7033438  -213.96 -0.62947496]]



Aucun commentaire:

Enregistrer un commentaire