I have a dataset that is something like this:
g_id event time_left home away
1 "TIP" 00:12:00 8 6
1 "SHOT" 00:11:48 8 6
1 "MISS" 00:11:20 8 6
1 "TOV" 00:11:15 8 6
1 "SHOT" 00:10:40 8 6
2 "REB" 00:11:48 7 3
2 "FOUL" 00:11:35 7 3
2 "FT" 00:11:33 7 3
2 "FT" 00:11:31 7 3
3 "TIP" 00:12:00 5 1
3 "MISS" 00:11:43 5 1
3 "REB" 00:11:42 5 1
3 "SHOT" 00:11:27 5 1
3 "TOV" 00:11:04 5 1
4 "SHOT" 00:11:39 9 4
4 "MISS" 00:11:17 9 4
4 "REB" 00:11:16 9 4
4 "SHOT" 00:10:58 9 4
I noticed that my problem is somewhat similar to this one in MySQL but I was wondering if this can be done in Pandas as well. As you may have noticed, the data is grouped by 'g_id' and some of the sequences start with 'TIP' and others don't. What I want to do is go by 'g_id' and if the 'g_id' doesn't start with event = 'TIP', insert a row that contains 'TIP' in that column, '00:12:00' in the 'time_left' column, and carry over the 'home' and 'away' columns that are in the first row. How can I do that? The real dataset has more columns, but I basically just need how to insert a new row where some column values are the same as the row they're going before and some are assigned new values.