I have the following dataframe:
df = pd.DataFrame({'ID': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
'Info': ['info1', 'info2', 'info3', 'info4', 'info5', 'info6',
'info7', 'info8', 'info9', 'info10', 'info11', 'info12'],
'Category': ['157/120/RGB', '112/54/RGB', '14/280/CMYK', '50/100/RGB',
'150/88/CMYK', '160/100/G', '200/450/CMYK', '65/90/RGB',
'111/111/G', '244/250/RGB', '100/100/CMYK', '144/100/G']})
I need to get a number of dataframes equal to the number of right-sided Category string patterns, that is RGB
, CMYK
, G
. Is there a way - maybe using regular expressions - to put just this string piece within getgroup
method in order to create these groups? For instance:
df_RGB = df.groupby('Category').getgroup('...RGB')
what should I replace dots with?