Is there a python code to perform the following task in python
If dataset means pandas.DataFrame then you can use

dataset['rate'] &lt; 6


to get dataset with values True/False which can sum because True is converted to 1 and False is converted to 0

count = sum(dataset['rate']&lt;6)  # 17


If you get number of all rows in dataset len(dataset) then you can calculate percentage value

percent = count/len(dataset)   # 0.8 (80%)




Working example

import pandas as pd

dataset = pd.DataFrame({
    'rate': [9, 6, 2, 2, 8, 5, 4, 4, 5, 4, 4, 2, 4, 5, 3, 5, 7, 3, 5, 4, 1]
})

count = sum(dataset['rate']&lt;6)
percent = count/len(dataset)

print(count, percent, '{:.2%}'.format(percent))


Result

17 0.8095238095238095 80.95%