Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

303
Views
concatenar multiíndice en un solo índice en la serie pandas

Tengo un pandas.Series con multiíndice:

 index = pd.MultiIndex.from_tuples([('one', 'a'), ('one', 'b'), ('two', 'a'), ('two', 'b')]) s = pd.Series(np.arange(1.0, 5.0), index=index) print(s) one a 1.0 b 2.0 two a 3.0 b 4.0 dtype: float64

Quiero fusionar el multiíndice en un solo índice de la siguiente forma:

 one_a 1.0 one_b 2.0 two_a 3.0 two_b 4.0 dtype: float64

¿Hay una buena manera de hacer esto?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Usar map con join :

 s.index = s.index.map('_'.join)

La alternativa es list comprehension :

 s.index = ['{}_{}'.format(i, j) for i, j in s.index] print (s) one_a 1.0 one_b 2.0 two_a 3.0 two_b 4.0 dtype: float64
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!