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

284
Views
que no sea el valor máximo, reemplace todos los valores a 0 en cada columna (pandas, python)

tengo un df que quiero reemplazar valores que no son el valor máximo para cada columna a 0.

código:

 data = { "A": [1, 2, 3], "B": [3, 5, 1], "C": [9, 0, 1] } df = pd.DataFrame(data)

muestra df:

 ABC 0 1 3 9 1 2 5 0 2 3 1 1

resultado tratando de obtener:

 ABC 0 0 0 9 1 0 5 0 2 3 0 0

Consejo amable. muchas gracias

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Use DataFrame.where con valores max de comparación:

 df = df.where(df.eq(df.max()), 0) print(df) ABC 0 0 0 9 1 0 5 0 2 3 0 0
over 4 years ago · Santiago Trujillo Report

0

Tratar:

 df[df!=df.max()] = 0

Producción:

 ABC 0 0 0 9 1 0 5 0 2 3 0 0
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!