I have the following pandas DataFrame.
import pandas as pd
df = pd.read_csv('filename.csv')
print(df)
sample column_A
0 sample1 6/6
1 sample2 0/4
2 sample3 2/6
3 sample4 12/14
4 sample5 15/21
5 sample6 12/12
.. ....
The values in column_Aare not fractions, and this data should be processed in such a way that I can convert each value to 0sand 1s(not convert integers to my binary copies).
"Numerator" above gives the total number 1s, and "denominator" gives the total number 0sand 1stogether.
So, the table should be in the following format:
sample column_A
0 sample1 111111
1 sample2 0000
2 sample3 110000
3 sample4 11111111111100
4 sample5 111111111111111000000
5 sample6 111111111111
.. ....
I have never parsed an integer to output lines 0 and 1 like this. How to do it? Is there a pandas method to use with expressions lambda? Pythonic string parsing or regex?