Home > Enterprise >  unable to split column in pandas dataframe
unable to split column in pandas dataframe

Time:07-20

I have a dataframe in which one of the column has multiple values, See dummy dataset below

import pandas as pd
data = pd.DataFrame({"A" : ["EmpA","EmpB","EmpC","EmpD","EmpI"], 
                      "Summary" :["XX1","XX2","XX3","XX4","XX5"],
                      "DummyCol" :["TextAAAA","TextAAAA","TextAAAA","TextAAAA","TextAAAA"],
                     "MonthSales" : ['25:50:30','30:40','35:43:45:46:100','40:3','45:32:1:23:90']})

enter image description here

I applied the split function however it results it giving back only the single columns , is there any other efficient way apart from getting the results and using a join to combine the output..

data['MonthSales'].str.split(":",expand=True)

Desired data structure

enter image description here

CodePudding user response:

You can use Output of the dataset

  • Related