I have 2 dfs:
ipos_df:
index | Date | Symbol | Company Name | IPO Price | Current | Return |
---|---|---|---|---|---|---|
33 | 2024-02-27 00:00:00 | SMXT | SolarMax Technology, Inc. | $4.00 | $10.42 | 160.50% |
34 | 2024-02-22 00:00:00 | VHAI | Vocodia Holdings Corp | $4.25 | $0.16 | -96.29% |
35 | 2024-02-21 00:00:00 | DYCQ | DT Cloud Acquisition Corporation | $10.00 | $10.35 | 3.50% |
36 | 2024-02-16 00:00:00 | CHRO | Chromocell Therapeutics Corp | $6.00 | $1.77 | -70.50% |
37 | 2024-02-14 00:00:00 | UMAC | Unusual Machines, Inc. | $4.00 | $1.30 | -67.50% |
and history_data:
index | Open | High | Low | Close | Volume | Dividends | Stock Splits | Symbol | Adj Close | Date |
---|---|---|---|---|---|---|---|---|---|---|
2024-02-27 | 3.5 | 9.350000381469727 | 3.5 | 8.0 | 2840400.0 | 0.0 | 0.0 | SMXT | NaN | 2024-02-27 00:00:00 |
2024-02-28 | 6.420000076293945 | 7.239999771118164 | 5.599999904632568 | 5.860000133514404 | 243200.0 | 0.0 | 0.0 | SMXT | NaN | 2024-02-28 00:00:00 |
2024-02-29 | 5.739999771118164 | 5.840000152587891 | 4.300000190734863 | 4.889999866485596 | 130000.0 | 0.0 | 0.0 | SMXT | NaN | 2024-02-29 00:00:00 |
2024-03-01 | 3.940000057220459 | 5.150000095367432 | 3.799999952316284 | 4.880000114440918 | 485000.0 | 0.0 | 0.0 | SMXT | NaN | 2024-03-01 00:00:00 |
2024-03-04 | 4.730000019073486 | 5.099999904632568 | 4.257999897003174 | 4.659999847412109 | 114300.0 | 0.0 | 0.0 | SMXT | NaN | 2024-03-04 00:00:00 |
And I need to create 30 columns (for 30 days) in ipos_df with close price (from history_data df) n days after IPO.
Trying this:
for i in range(1,30):
ipos_df['growth_'+str(i)+'d'] = history_data.loc[(history_data['Symbol'].equals(ipos_df['Symbol'])) & ((history_data['Date'] - timedelta(days=i)).equals(ipos_df['Date'])), history_data['Close']].dropna().values[0][0]
Getting this:
KeyError: ‘False: boolean label can not be used without a boolean index’
New contributor
PyCoder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.