• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: split before first comma in pandas and output

Resolved: split before first comma in pandas and output

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I want to output the following table in pandas. I only have the description column so far but I want to split on the comma and output the contents before the comma in the commondescrip column.
I have the description column right now, I need the commondescrip column
description commondescrip
00001 00001
00002 00002
00003,Area01 00003
00004 00004
00005,Area02 00005

I tried
but it gives me NaN for those rows that have Area.
How can I fix it so that I can achieve the above the table and split it to output before the comma?

Answer:

Here is one way to do it

If you have better answer, please add a comment about this, thank you!

dataframe pandas python
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Getting ‘502 Bad Gateway’ while deploying Springboot app in EKS

24/03/2023

Resolved: Why is NGINX’s $request_uri empty?

24/03/2023

Resolved: How to convert Java bytecode to Webassembly using CheerpJ compiler

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.