Home > Software engineering >  I want line break after slicing by \t pandas
I want line break after slicing by \t pandas

Time:11-14

I want to do line break after slicing by \t. Could you possibly know about this?

columns
A00\t콜레라\tCholera

=>

columns
A00
콜레라
Cholera

CodePudding user response:

You can first split your column then explode:

df['column'] = df['column'].str.split("\t")
df.explode("column")

CodePudding user response:

Can you check if this works?

import pandas as pd
df = pd.DataFrame({'columns':['A00\t콜레라\tCholera']})
new_df = pd.DataFrame(df['columns'].str.split('\t').tolist()).stack()
new_df

Taken from this Medium article

  • Related