Hello there i have the following dataframe:
Name Lastname ticket
0 Peter Pan Ticket1
1 Null Null $20
i want to make it look like this:
Name Lastname ticket ticketprice
0 Peter Pan Ticket1 $20
1 NULL NULL Null Null
but it seems to be really difficult for me. Does anyone know how this works?
>Solution :
Given that your odd columns contain the ticket price, one way you could do this is by copying the column into another ticketprice column and shifting that column up by one like so:
import pandas as pd
df['ticket_price'] = df['ticket'].shift(-1)
df = df.iloc[::2]
Then delete all rows that have an even index to remove the empty line. In the example above df is the pandas dataframe containing your base data.