For each row in df, I want to count how many value belonging to column AA and B greater than 2 and save this count to a new column in the same df. So in the df below, row 0, the count =1, in row 1, count=2. Any help please?
import numpy as np
import pandas as pd
df = pd.DataFrame({
"AA": [3,6,0,3,4],
"B": [1,5,1,1,4],
"W": [1,2,1,1,9]
})
df
source https://stackoverflow.com/questions/73365411/count-number-of-columns-that-meet-condition
Comments
Post a Comment