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 8789261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:21:22+00:00 2026-06-13T22:21:22+00:00

So I have a sample data set like this in csv:- name team date

  • 0

So I have a sample data set like this in csv:-

name    team    date       score
John    A   3/9/12      100
John    B   3/9/12      99
Jane    B   4/9/12      102
Peter   A   9/9/12      103
Josie   C   11/9/12     111
Rachel  A   30/10/12    98
Kate    B   31/10/12    103
David   C   1/11/12     104

Executing the following:-

from pandas.io.parsers import read_csv

df = read_csv("data/Workbook1.csv", index_col=["team", "name"])

df

                 date  score
team name                   
A    John      3/9/12    100
B    John      3/9/12     99
     Jane      4/9/12    102
A    Peter     9/9/12    103
C    Josie    11/9/12    111
A    Rachel  30/10/12     98
B    Kate    31/10/12    103
C    David    1/11/12    104

How do I compress the first index (“team”) further so that I don’t have duplicate values? To become:-

                 date  score
team name                   
A    John      3/9/12    100
     Peter     9/9/12    103
     Rachel  30/10/12     98
B    John      3/9/12     99
     Jane      4/9/12    102
     Kate    31/10/12    103
C    Josie    11/9/12    111
     David    1/11/12    104
  • 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-13T22:21:24+00:00Added an answer on June 13, 2026 at 10:21 pm

    Figured it out myself.

    df = read_csv("data/Workbook1.csv")
    
    df
    
         name team      date  score
    0    John    A    3/9/12    100
    1    John    B    3/9/12     99
    2    Jane    B    4/9/12    102
    3   Peter    A    9/9/12    103
    4   Josie    C   11/9/12    111
    5  Rachel    A  30/10/12     98
    6    Kate    B  31/10/12    103
    7   David    C   1/11/12    104
    
    df2 = df.pivot('team', 'name').stack()
    
    df2
    
                     date  score
    team name                   
    A    John      3/9/12    100
         Peter     9/9/12    103
         Rachel  30/10/12     98
    B    Jane      4/9/12    102
         John      3/9/12     99
         Kate    31/10/12    103
    C    David    1/11/12    104
         Josie    11/9/12    111
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a sample data like this ID DATE TIME STATUS --------------------------------------------- A 01-01-2000
I have data like this. Following is the sample data. alt text http://a.imageshack.us/img695/441/custoemrids.png I
I have a employee table and the sample data in it is like this.
I have fit a simple bi-variate VAR model to this data set and I
I have a sample data table(id, name, date_create) table(1, 'Iphone 4S', '2012-06-18 17:19:05') //
I have a sample data game(id, name) 1 | Avatar 2 | Angry Bids
I have below sample data. AID Date Title ----- ---------- ------ 1 2011-12-12 test1
I have the following sample data: Id Name Quantity 1 Red 1 2 Red
I have data that always looks something like this: alt text http://michaelfogleman.com/static/images/chart.png I need
I have some sample data like so: var data = { section: { 1:

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.