'Create new dataframe which summarizes the number of occurences for different numeric ranges of some other column

I have dataframe df as shown in the first photo. Green rows are the ones which have column Condition1 as 'Yes'. Yellow rows are the ones which have BOTH columns Condition1 and Condition2 as 'Yes'.

Question: See second photo which shows desired output which is a new dataframe in which:

(1). Column 'Count_Condition1' contains the number of times green row occurs. The column 'Count_Condition_1&2' contains the number of times yellow rows occur.

(2). In addition to (1), I would like to split the column 'Vol' to different ranges (see second photo) and the counts be displayed accordingly.

For example, there are 3 instances when Condition1= 'Yes' and the data range for Vol is between 0.2 to 0.2999.

enter image description here

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source