Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8519509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:16:09+00:00 2026-06-11T06:16:09+00:00

Suppose I have a pandas DF with ‘A’,’B’,’C’ as column name A B C

  • 0

Suppose I have a pandas DF with ‘A’,’B’,’C’ as column name

A    B   C 
a1  b11 c11
a1  b12 c12
a2  b21 c21
a2  b22 c22

I can group by ‘A’, but can I get

A  B  C
a1 [b11,b12], [c11,c12]
a2 [b21,b22], [c21,c22]

without any aggregation? Hopefully the order (b11 before b12) is kept as occured in the original table.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:16:10+00:00Added an answer on June 11, 2026 at 6:16 am

    I don’t know how to do exactly what you want, but perhaps this is close enough:

    In [23]: df = pd.DataFrame({'A' : ['a1', 'a1', 'a2', 'a2'],
                                'B' : ['b11', 'b12', 'b21', 'b22'],
                                'C' : ['c11', 'c12', 'c21', 'c22']})
    
    In [24]: grpA  = df.groupby('A')
    In [25]: a1 = grpA.get_group('a1')
    

    Using that I then get:

    In [26]: a1['B']  # or a1.B
    Out[26]: 
    0    b11
    1    b12
    Name: B
    

    also:

    In [39]: import numpy as np
    
    In [40]: np.array(a1.B)
    Out[40]: array([b11, b12], dtype=object)
    

    and finally:

    In [41]: grpdA.get_group('a1').B.tolist()  # leave off `.tolist()` to get a series
    Out[41]: ['b11', 'b12']
    

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose we have the name written in any none-latin letters - languages, like Arabic,
Suppose I have the following table: PERSON : ID INT NAME STRING LASTNAME STRING
Suppose I have a two column matrix. How do I pack the columns into
Suppose I have a table called Companies that has a DepartmentID column. There's also
Suppose have following beach definition: <bean id=singletonBean class=...> <property name=instanceBean ref=instanceBean/> </bean> <bean id=instanceBean
Suppose I have the example TimeSeries below: ts = pandas.TimeSeries({'a':[1,2,3,4,5], 'b':[6,7,8,9,10]}) The best method
suppose i have a .on() function wherein i select multiple ids $(#i, #am, #your,
Suppose I have a large list of words. For an example: >>> with open('/usr/share/dict/words')
Suppose I have a pure virtual method in the base interface that returns to
Suppose I have a static method of my class that returns an object of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.