I am trying to shift certain rows in a .csv down without losing the last row. Say if you use df.shift(1), it will return the shifted dataframe, removing the last row of data. What I'm wanting is it to shift without losing the last row of data.
Original (data):
example1,example1
example2,example2
example3,example3
What happens after data.shift(1):
NaN,NaN
example1,example1
example2,example2
What I would like:
NaN,NaN
example1,example1
example2,example2
example3,example3
Maybe creating a row on the end filled with NaN would fix this? (I don't know how to fill cells with NaN).
Here is my actual code where I am selecting certain rows:
import pandas
data = pandas.read_csv('path/test.csv', header=False,
yes = data.iloc[2:3].shift(1)
print(yes)
output:
NaN,NaN
example2,example2