In figure 1 we can see that in the column named "No1" is not matching with column named "No" in terms of Number of Rows in both columns. In the column named "No1" there is one number missing which is "3". I want to write a code in which python code compares column "No1" and "No". When comparing if code finds that there is missing number it will enter a row with that missing number which is "3" and rest of the cell in that row should be entered as "NaN".Then code should scan again both the column and compare the value of both the column, if the column values are not matching it will enter a row and would enter a number according to the missing number which we get by scanning the both columns and rest cell of the row should be filled with "NaN". This process should go until the column named "No1" and column named "No" doesnot fill with the missing number in both the columns.From fig 2(Solution) we can see that in column "No1", row with number 3,22 was entered and in column "No", row with number 20 was entered.
Can somebody give me some idea how to develop this code?
I tried to match both the columns and it was partially working but I am unable to enter a new row with the missing number.I have csv file for this data and I have entered in python through pandas dataframe.
Asked
Active
Viewed 21 times
0
-
It's not clear what you have as input, but use a `merge` or `concat` – mozway Oct 12 '22 at 12:02