Need to add new rows to current df, based on conditions.
What I want to do is check the Sales Oder and if contains more than one order add new rows to df and update all columns remain as same as the current row but need to update Planned Shift Production(m) and Actual Shift Production(m) based on current row's AvgPlannedShiftProd and AvgActualShiftProd. End goal is to maintaining one Sale Order for each row.
df:
T={'Date': {1195: '2021-05-24',
1196: '2021-05-24',
1197: '2021-05-25',
1198: '2021-05-25',
1199: '2021-05-26',
1200: '2021-05-26'},
'Machine No': {1195: 'M-1',
1196: 'M-1',
1197: 'M-1',
1198: 'M-1',
1199: 'M-1',
1200: 'M-1'},
'Shift': {1195: 'Day',
1196: 'Night',
1197: 'Day',
1198: 'Night',
1199: 'Day',
1200: 'Night'},
'Sales Order': {1195: 'Z21',
1196: 'A1',
1197: 'B1-B2-B3-B4-B5',
1198: 'B1-B2-B3-B4-B5',
1199: 'B1-B2-B3-B4-B5',
1200: 'B1-B2-B3-B4-B5'},
'Quality No': {1195: 'C100',
1196: 'C100',
1197: 'C100',
1198: 'C100',
1199: 'C100',
1200: 'C100'},
'Planned Shift Production (m)': {1195: 0,
1196: 0,
1197: 4240,
1198: 4232,
1199: 0,
1200: 0},
'Actual Shift Production (m)': {1195: 3611,
1196: 3384,
1197: 3097,
1198: 2989,
1199: 0,
1200: 0},
'NoOfSalesOrders': {1195: 1.0,
1196: 1.0,
1197: 5.0,
1198: 5.0,
1199: 5.0,
1200: 5.0},
'AvgPlannedShiftProd': {1195: 0.0,
1196: 0.0,
1197: 848.0,
1198: 846.4,
1199: 0.0,
1200: 0.0},
'AvgActualShiftProd': {1195: 3611.0,
1196: 3384.0,
1197: 619.4,
1198: 597.8,
1199: 0.0,
1200: 0.0}}
pd.DataFrame.from_dict(T)
Sample of Expected Output:
Thnaks in advance !!!!!!!!!!

