AnswerBun.com

CASE WHEN SQL Type Statement in pandas

I’m trying to create a new column called Class which is a calculated column.
Basically when the Math class is NA then the class will be the CS class, otherwise it will be vice versa.

How can I do this in python? Table name is Classes

MathClass |  CSClass |  Class
------------------------------
Trig      |  NA      |  Trig
NA        |  Java    |  Java
NA        |  Python  |  Python  

Data Science Asked by Eisen on December 31, 2020

1 Answers

One Answer

Replace the missing value with empty string and add these columns up

Classes.fillna(value='').sum(axis=1)

Answered by chzhrr on December 31, 2020

Add your own answers!

Related Questions

NLP data cleaning and word tokenizing

1  Asked on February 14, 2021 by copyofa

     

Multivariate analysis

2  Asked on February 14, 2021 by sanjeewa-dayarathne

 

Heuristics in A* algorithm

0  Asked on February 13, 2021

 

Spatially constrained geospatial similarity

1  Asked on February 12, 2021 by overflow2341313

         

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved.