How do I select and store columns greater than a number in pandas?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How do I select and store columns greater than a number in pandas in Python. So Here I am Explain to you all the possible Methods here.

How do I select and store columns greater than a number in pandas?

1. How do I select and store columns greater than a number in pandas?

Sample DF:
In : df = pd.DataFrame(np.random.randint(5, 15, (10, 3)), columns=list('abc')) In : df Out:

2. select and store columns greater than a number in pandas

Sample DF:
In : df = pd.DataFrame(np.random.randint(5, 15, (10, 3)), columns=list('abc')) In : df Out:

Method 1

Sample DF:

In : df = pd.DataFrame(np.random.randint(5, 15, (10, 3)), columns=list('abc'))

In : df
Out:
a   b   c
0   6  11  11
1  14   7   8
2  13   5  11
3  13   7  11
4  13   5   9
5   5  11   9
6   9   8   6
7   5  11  10
8   8  10  14
9   7  14  13

present only those rows where b > 10

In : df[df.b > 10]
Out:
a   b   c
0  6  11  11
5  5  11   9
7  5  11  10
9  7  14  13

Minimums (for all columns) for the rows satisfying b > 10 condition

In : df[df.b > 10].min()
Out:
a     5
b    11
c     9
dtype: int32

Minimum (for the b column) for the rows satisfying b > 10 condition

In : df.loc[df.b > 10, 'b'].min()
Out: 11

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.