0 0 votes I'm creating a new data frame with the most used items grouped together. But I got the following error when grouping through ID and items. ValueError: Length mismatch: Expected axis has 60 elements, new values have 2935849 elements. df = sales_df[sales_df['shop_id'].duplicated(keep=False)] df['Grouped'] = sales_df.groupby('shop_id')['item_name'].transform(lambda x: ','.join(x)) df2 = df[['shop_id', 'Grouped']].drop_duplicates() In the aforementioned code, I'm making a data frame with respect to shop id and then grouping through shop items. My objective here is to group items with similar ID. Exploratory Data Analysis data python + – aryansan 120 points 1 1 3 answer comment Share 0 reply Please log in or register to add a comment.