Why does storing the output of .count() result in all 1's or 0's? I have a dataframe which I run loc on to find all values within the loc parameters. Whatever the loc returns gets stored in a variable. I try to use this variable to store it in another dataframe column but it only returns 1's and 0's for the whole column.
How would I get what is being printed to be properly appended to a new dataframe?
I think the .count() has something to do with it, meaning it is changing the value of s4 and s5 when applied to the new dataframe.
for name in pros_unique:    
    s4 = df.loc[(df.pros_split == name) &amp; (df.orc_4 == 1)].orc_4.count()
    s5 = df.loc[(df.pros_split == name) &amp; (df.orc_5 == 1)].orc_4.count()

    tots_df['orc_4_totals'] = s4
    tots_df['orc_5_totals'] = s5
    # This prints out in the correct format 
    print(name, s4, s5)

Output of print statement:
name1 77 22
name2 62 32
name3 43 29
name4 1 1
name5 61 24

This is the tots_df dataframe:

pros    orc_4_totals    orc_5_totals
0   name1     1        0
1   name2     1        0
2   name3     1        0
3   name4     1        0
4   name5     1        0
```
Because on each loop you assign a single value to the entire column:
   tots_df['orc_4_totals'] = s4    # entire column orc_4_totals = s4!

(the same thing for the other column.
It equals all ones then, just because your final loop value fills it with 1.
You need to insert single values instead, for each row of your target dataframe.
However, because I don't know if your target dataframe tots_df has an existing index, I would suggest first saving the values in a list, then assigning them:
orc_4_values = []
orc_5_values = []
for name in pros_unique:
    # perform your checks, then assign using:
    s4 = df.loc[(df.pros_split == name) &amp; (df.orc_4 == 1)].orc_4.count()
    s5 = df.loc[(df.pros_split == name) &amp; (df.orc_5 == 1)].orc_4.count()
    orc_4_values.append(s4)
    orc_5_values.append(s5)

# Add to dataframe after the loop
tots_df['orc_4_totals'] = orc_4_values
tots_df['orc_5_totals'] = orc_5_values