I have a large dataset (around 2 GB excel), for which I need to create multiple columns out of one column. I am getting results but it is taking too much time to produce new columns. Also many times I am getting a memory error. Is there another efficient method to achieve my required results? Please help me if possible. the code sample is as below: import pandas as pd
data = {'product_name': ['laptop-active', 'printer-active', 'tablet-active', 'desk-passive', 'chair-passive'],
'price': [1200, 150, 300, 450, 200]
}
df = pd.DataFrame(data)
print (df)
def namefun(s):
y=s.split("-")
return y[0],y[1]
df[['A','B']]=df.apply(
lambda row: pd.Series(namefun(row['product_name'])), axis=1)