I am trying to assign values starting at 1 - length of the dataframe to a column that currently has all NaN values.

Asked
Active
Viewed 26 times
-1
Naveed
- 11,495
- 2
- 14
- 21
Jeremy Wagerik
- 3
- 2
-
Welcome to [SO](https://stackoverflow.com/tour). Please check [How to Ask](https://stackoverflow.com/help/how-to-ask), and provide a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). Also [don't provide datasets as an image](https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors-when-asking-a-question), see [How to make pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) instead. Note to reduce the dataset to the necessary minimum. – MagnusO_O Oct 18 '22 at 17:14
1 Answers
0
You can try like this. Assuming Data frame names as df. if you want to start from zero
df['member_id'] = df.index
If you want to start from 1 (Your case)
df['member_id'] = df.index+1
Bhargav - Retarded Skills
- 3,154
- 1
- 6
- 22