Last active
July 24, 2019 19:43
-
-
Save mberrien-fitzsimons/a4b55f6b858ecb47ca3494f5fad477c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put data processing code into function | |
def process_alphavantage_data_create_dow_dummies(raw_data_file): | |
raw_data_file['timestamp'] = pd.to_datetime(raw_data_file['timestamp']) | |
raw_data_file['day_of_week'] = raw_data_file['timestamp'].dt.day_name() | |
dummies = pd.get_dummies(raw_data_file['day_of_week']) | |
raw_data_file.drop(columns=['day_of_week'], inplace=True) | |
raw_data_file = pd.concat([raw_data_file, dummies], axis=1) | |
# we are only interested in running a regression of volume against the dummy | |
# variables for days of the week. Because of this we will drop the remaining | |
# variables before importing it to our processed data folder | |
raw_data_file.drop(columns=['timestamp', 'open', 'high', 'low', 'close', | |
'adjusted_close', 'dividend_amount', | |
'split_coefficient'], inplace=True) | |
return raw_data_file | |
# Let's save our file | |
msft_proc.to_csv('../data/03_processed/msft_proc.csv', index=False) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment