samedi 28 octobre 2017

Creating a dataframe using pandas and random module

I want to create a dataframe using pandas where 1 column is 'EmployeeID' and the second one is 'skill' set he has ranging form 1 to 5. The 'EmployeeID' column should have unique values whereas the 'skill' column can have repetitive values. 1. I tried to generate the 'EmployeeID' using the below code:

    df = pd.DataFrame({'EmployeeID':[random.sample(range(123456,135000),100)]})

but the result is not what i expected. It generated all the numbers and put them in one row

enter image description here

  1. Random.sample is giving me unique values. How can i generate 100 repetitive values in a given range? Tried using randint but it doesn't have the option of passing the count of numbers to generate



Aucun commentaire:

Enregistrer un commentaire