2,111 views
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.

Please log in or register to answer this question.

Related questions

0 0 votes
1 1 answer
1.0k
1.0k views
1 1 vote
1 1 answer
1.2k
1.2k views
0 0 votes
0 0 answers
587
587 views
aaditi asked Nov 23, 2020
587 views
0 0 votes
0 0 answers
798
798 views
Anas asked Nov 29, 2021
798 views
So say I have a column with categorical data like different styles of temperature: 'Lukewarm', 'Hot', 'Scalding', 'Cold', 'Frostbite',... etc.I know that we can use pd.ge...
1 1 vote
0 0 answers
736
736 views
sujitha asked Feb 11, 2019
736 views
I have a tensorflow LSTM model for predicting the sentiment. I build the model with the maximum sequence length 150. (Maximum number of words) While making predictions, i...