Given a sequence of numbers, first convert to interval and convert to dictionary as per sequence of number and then after that map it with a column in DataFrame as shown in DataFrame below.
Query-1 how to create interval from above sequence into dictionary
given_sequence = [-100, 2, 5, 8, 10, 15]# Given sequence
idict = {-100: '<2',
2:'2-5',
5:'5-8',
8:'8-10',
10:'10-15',
15:'>15'}
Query-2 how to map to a column as shown in below screen shot with dictionary and map function
import pandas as pd
import random
# create an Empty DataFrame object
df = pd.DataFrame()
df['col1'] = [random.randint(1, 10) for i in range(0, 10)]
df['mapped'] = df['col1'].map(idict)
** Expected Output**
