I am using pandas data frame to read an excel file
import pandas as pd
df = pd.read_excel('inputExcel.xlsx')
df
df output is shown below
Unnamed: 0 5 4 3 2 1
0 row1 NaN r1<1:0> NaN NaN NaN
1 row2 NaN NaN r2<2:0> NaN NaN
2 row3 r3<4:0> NaN NaN NaN NaN
3 row4 NaN r4<3:0> NaN NaN NaN
Now I would like to modify the above data frame as shown below
Unnamed: 0 5 4 3 2 1
0 row1 NaN r1<1> r1<0> NaN NaN
1 row2 NaN NaN r2<2> r2<1> r2<0>
2 row3 r3<4> r3<3> r3<2> r3<1> r3<0>
3 row4 NaN r4<3> r4<2> r4<1> r4<0>
Basically it looks for content of each row and if it sees a bus in the format data<MSB:LSB>
it should copy the contents of the column MSB-LSB+1 times to the adjacent column in the same row as data<MSB>
data<MSB>-1
and so on upto data<LSB>
question from:
https://stackoverflow.com/questions/65837624/manipulate-a-column-or-a-few-columns-based-on-a-cell-value 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…