Skip to content

Instantly share code, notes, and snippets.

@alphazwest
Created November 29, 2021 23:18
Show Gist options
  • Save alphazwest/9019514ccc44febe9485ab5c70940a48 to your computer and use it in GitHub Desktop.
Save alphazwest/9019514ccc44febe9485ab5c70940a48 to your computer and use it in GitHub Desktop.
# Calculate Daily Range for each period
ETH['dr'] = ETH.apply(lambda x: x["High"] - x["Low"], axis=1)
# Result
High Low dr
Date
2021-05-18 3562.465088 3246.404053 316.061035
2021-05-19 3437.935791 1952.460205 1485.475586
2021-05-20 2993.145264 2170.229004 822.916260
2021-05-21 2938.205078 2113.347168 824.857910
2021-05-22 2483.983154 2168.124268 315.858887
... ... ... ...
2021-11-14 4689.842773 4516.935547 172.907227
2021-11-15 4764.636230 4546.599121 218.037109
2021-11-16 4891.704590 4144.334961 747.369629
2021-11-17 4300.306641 4107.125977 193.180664
2021-11-18 4343.557129 4052.962158 290.594971
[185 rows x 3 columns]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment