I have csv file, which contains missing column values, how to copy missing column value from previous row ?
product_id,name,modifier
1,test,cheese
,test,eggs
,test,onions
2,test2,cheese
,test2,eggs
,test2,onions
Above CSV data, gets below output
import pandas as pd
import numpy as np
df = pd.read_csv("pivot-products.csv")
df.pivot(index='product_id',columns='modifier') # <-- throws error
Above pivot code works fine with below dataset, where I manually copied it, how to cleanup in pandas to look like below ?
product_id,name,modifier
1,test,cheese
1,test,eggs
1,test,onions
2,test2,cheese
2,test2,eggs
2,test2,onions