I'm using Python 3.8.8
I have a DataFrame structured like this:
| A | B |
|---|---|
| 0 | 1 |
| 1 | 2 |
| 2 | 1 |
| 3 | 7 |
| 4 | 7 |
| 5 | 8 |
and an array:
C = [3, 4, 7]
I would like to add an array "C" as a new column to the DataFrame. The problem is this array has a different length of index than the df. I would like to make up for the difference in length in C by filling the empty cells with NaNs. My desired result would look something like:
| A | B | C |
|---|---|---|
| 0 | 1 | NaN |
| 1 | 2 | NaN |
| 2 | 1 | 3 |
| 3 | 7 | 4 |
| 4 | 7 | 7 |
| 5 | 8 | NaN |
What I am looking for specifically is a way to add C starting at a specific index of the df, but I don't know how to work around the discrepancy between the length of the df and array.
Thank you for your time