finding indexes of 1's in a bit string and storing these indexes in a list — Index should be started from 1 not 0

I am finding indexes of 1’s in a bit string successfully. However, these indexes start from 0. Sample Data: initial_pop 000000000000000000000000000001011000000 000000001000000000000001000000000010000 000000000000000000000000000000010011000 000000000000001001000000000000010000000 000000000000000000010000001000000010000 1000000000100000000010000000000000000000 1000000010000000000001000000000000000000 1001000000000000000010000000000000000000 000000000000100000000000100000000000010 000000000110000000000000000000001000000 Now, If we look at the 6th, 7th, and 8th data rows, values are placed at index 0 by default. My sample code: #Getting 1’s… Read More finding indexes of 1's in a bit string and storing these indexes in a list — Index should be started from 1 not 0

counting 1's in a bit string to keep positions in a variable and then accessing each value

I am finding 1’s in a bit string and then storing them. Sample Data: Sample code: def indices(chromosome): return {i for i,c in enumerate(chromosome) if c==’1′} for ind in df_initial_pop[‘initial_pop’].index: locations = indices(df_initial_pop[‘initial_pop’] [ind]) print (locations) Output: {32, 29, 31} {8, 34, 23} {34, 35, 31} {17, 14, 31} {26, 19, 34} Now, I want… Read More counting 1's in a bit string to keep positions in a variable and then accessing each value