I just started learning pandas and this is a very simple question. Believe me, I was looking for an answer, but I can not find it.
Can you run this python code?
import pandas as pd
df = pd.DataFrame({'A':[1,0], 'B':[2,4], 'C':[4,4], 'D':[1,4],'count__4s_abc':[1,2],'sum__abc':[7,8]})
df
How to create a column "count__4s_abc" in which I want to count how many times the number 4 appears only in AC columns? (Ignoring column D.)
How to create a column "sum__abc" in which I want to sum the sums only in AC columns? (Ignoring column D.)
Thanks so much for any help!
source
share