So, I have this col which I have saved as a series(els):
1 B S C
2 B S C
6 B S C
7 B S C L
8 B S C L
...
2522 B S* C Sa
2523 B S* C Sa
2524 B S* C Sa
2526 B S C
2529 B S C
And I want to create a list of binary values depending upon the letter 'B' residing in els. My most effective attempt was:
ima_b = [] for line in els.iteritems(): if 'B' in line: ima_b.append(1) else: ima_b.append(0) print(ima_b)
Which returns:
[0,0,0,0,0,...0,0,0,0,0]
I've tried searching for solutions and playing with the code for 3 days (over 8 hours). I just cannot figure out what I am doing wrong here and I am about to lose my mind. Examples of things I've tried: .loc, converting to different types and reformatting, converting back. When I tried reformatting, it would cut out some of the data.
My end goal with this list is to create a True/False column for if 'B' is located in els and graph it.