How can I replace NaN values with other values in the CustomerID column if they have a same InvoiceNo?
Assuming that each invoice id has only 1 unique customer id something like this should work:
df[&quot;CustomerID&quot;] = df.groupby(&quot;InvoiceNo&quot;)[&quot;Customer ID&quot;].apply(lambda x: x.ffill().bfill())

The code above simply makes groups based on the customer id and forward an backward fills all NA values.