0

Imagine I have the following data:

    Index   Local ID    Number of Dependents
0   PT1      362               2.0
1   PT2      363               1.0
2   PT3      369               3.0
3   PT4      373               2.0

How can I replicate the rows of the dataframe n times being n the value in the column "Number of Dependents"? and change the value in the column all to "1" (without the .0). The expected result would be:

    Index   Local ID    Number of Dependents
0   PT1      362               1
0   PT1      362               1
1   PT2      363               1
2   PT3      369               1
2   PT3      369               1
2   PT3      369               1
3   PT4      373               1
3   PT4      373               1

Thank you!

Paulo Cortez
  • 609
  • 4
  • 10

0 Answers0