I want line break after slicing by t pandas

Question:

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

columns
A00t콜레라tCholera

=>

columns
A00
콜레라
Cholera
Asked By: 이승우

||

Answers:

You can first split your column then explode:

df['column'] = df['column'].str.split("t")
df.explode("column")
Answered By: Tranbi

Can you check if this works?

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

Taken from this Medium article

Answered By: abhilash966

I am sorry but can you explain a little with an example?

if this is a column then why need it in a row?

pd.read_csv(file_name, sep = "t")

pd.read_table(file_name)

I can help in panda if you upload more details of the requirements.

Answered By: krishna
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.