Created
June 12, 2021 04:40
-
-
Save cameronShadmehry/57d791ea60284748c6e6fe3d3448e8b7 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
# Convert the data into a dataframe. | |
df = pd.DataFrame(data=test['data']) | |
# Derived attributes from the data. | |
df['dollarAmount'] = df['change']*df['transactionPrice'] | |
df['insiderPortfolioChange'] = df['change']/(df['share'] - df['change']) | |
# print(type(df['transactionPrice'][0])) | |
conditions = [ | |
(df['change'] >= 0) & (df['transactionPrice'] > 0), | |
(df['change'] <= 0) & (df['transactionPrice'] > 0), | |
(df['transactionPrice'] == 0) | |
] | |
values = ['Buy', 'Sale', 'Gift'] | |
df['buyOrSale'] = np.select(conditions, values) | |
print(df) | |
df.to_csv('YOUR PATH\\'+stock+'.csv', index=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment