For context, I am editing a simple script that outputs stock information to a Pandas dataframe. I am currently editing the script itself within VS Code, and build it there. I started to notice that my one function was no longer returning output, just returning a blank dataframe. (That function is "combined_events"). I noticed that it was using the depreciated "append" function from pandas, and I made a code change to use pandas.concat to combine dataframes. When I made the changes and saved the Python script, I restarted the shell, and re-imported necessary modules to the shell. When I retried with the new edits, the dataframe still returned blank.
I do not have Git or a dedicated version control, as I just use this script for some personal calculations. Sample of what I am seeing is below:
from projects.api import stock_functions as sf
l = ['O','STAG','MAIN','LAND','PECO','SCHD']
e = sf.combined_events(l)
e
Empty DataFrame
Columns: []
Index: []
import pandas as pd
def combined_events(list_arg):
appEvents = pd.DataFrame()
for i in range(0,len(list_arg)):
try:
events = sf.get_event_data_to_dataframe(list_arg[i])
appEvents = pd.concat([appEvents,events],ignore_index=True)
#appEvents = appEvents._append(events)
except:
pass
return appEvents
e = combined_events(l)
e
Ticker Date Event Amount
0 O 2023-12-29 DIVIDEND 0.257
1 O 2023-11-30 DIVIDEND 0.256
2 O 2023-10-31 DIVIDEND 0.256
3 O 2023-09-29 DIVIDEND 0.256
4 O 2023-08-31 DIVIDEND 0.256
.. ... ... ... ...
63 PECO 2023-02-17 DIVIDEND 0.093
64 SCHD 2023-12-06 DIVIDEND 0.742
65 SCHD 2023-09-20 DIVIDEND 0.655
66 SCHD 2023-06-21 DIVIDEND 0.665
67 SCHD 2023-03-22 DIVIDEND 0.597
[68 rows x 4 columns]
I tried saving the Python script multiple times, restarted the shell IDLE, re-imported the module. I f I create the function within the IDLE and run it with other function from same script, it works within the IDLE. See code sample above.