Skip to content

Instantly share code, notes, and snippets.

@devmnj
Last active January 12, 2024 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devmnj/256d376df5d8602cb5014c7376376388 to your computer and use it in GitHub Desktop.
Save devmnj/256d376df5d8602cb5014c7376376388 to your computer and use it in GitHub Desktop.
Steps to prepare dataframe for Algo in Python
# I encounter proplem while using Historical data
# For yfinance most of the case the data is in good shape
# The first thing I am looking for index column, of numbers. if it exist, need to replace with datetime
# the last thing I want make sure that the date column is in panda datetime type otherwise have to covert it.
df =pd.DataFrame(data['Success'])
df =df[['datetime','open','high','low','close','volume']]
df['datetime']= pd.to_datetime(df['datetime'])
df.set_index('datetime', inplace=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment