vendredi 6 septembre 2019

Create a column with fixed values

I am trying to create a new column in dataframe with values :

data = [4.91,4.93,5.02,4.93,4.82,4.57,4.49,4.57,4.54,4.52,4.56,4.73]

I have more than 50,000 rows in the dataframe and I want the values to be assigned randomly to the new column.

so the idea is that these values would be assigned randomly and repeated in the column.

I was thinking of using lambda function with this logic :

df.assign(value=lambda x: #function here)

Can anyone suggest any other way or a simpler way for the same? I am not able to understand the logic the function for assigning the values randomly.

Thanks




Aucun commentaire:

Enregistrer un commentaire