data = {'1':['cd','aa','1a'],
'2':['ab','1b'],
'3':['1a']}
Wanted output:
data = {'1':['cd','aa','1a'],
'2':['00','ab','1b'],
'3':['00','00','1a]}
So I solved it as follows, but the problem is that it is too slow. Thank you for your reply
import pandas as pd
for i in (len(data)):
print(i)
count = 0
if ((data['1'].isna())[i]==True):
count = 3
elif ((data['2'].isna())[i]==True):
count = 2
elif ((data['3'].isna())[i]==True):
count = 1
data.loc[i] = data.loc[i].shift(count, fill_value='00')
there are 8 columns for my case, this is an example