Background: I am trying to create a Y-axis of 0s when there is Exit Date and 1s when there is both Investment and Exit Date and -1 when both are missing or anything else. I want to see the updates for 88k rows.
Here's my code:
for i in range(0,len(merged_port_cos_firms)):
inv = merged_port_cos_firms.iloc[i]['Investment_Date']
exi = merged_port_cos_firms.iloc[i]['Exit_Date']
print(i, len(exits), inv, exi, end = ' | ')
if not pd.isnull(exi):
exits.append(1)
print('Exited')
elif not pd.isnull(inv):
exits.append(0)
print('Not Exited')
else:
exits.append(-1)
print('Missing')
if i is not len(exits)-1:
print('Mismatch : ',i,len(exits)-1)
# break
And the output at around 257:
251 251 NaT NaT | Missing
252 252 NaT NaT | Missing
253 253 NaT NaT | Missing
254 254 NaT 2002-11-01 00:00:00 | Exited
255 255 NaT NaT | Missing
256 256 NaT NaT | Missing
257 257 NaT NaT | Missing
Mismatch : 257 257
258 258 NaT NaT | Missing
Mismatch : 258 258
All the other if blocks are executed multiple times before this. I have to get the exits
for 88k rows, so I am running the code without break. It is always entering the last if block only after 257. I don't understand why it is happening. Doesn't make any sense.