Deepest Fall per Ticker
prices has columns ticker and close, in day order. For a ticker, the fall on a day is how far its close sits below its highest close so far, as a share of that high: (high - close) / high. Return a dict from each ticker to its largest fall.
Example 1
prices {"ticker":["A","B","A","B","A","B"],"close":[100,50,80,60,120,30]}
returns {"A":0.2,"B":0.5}
A falls from 100 to 80, which is 0.2. B reaches 60 and then drops to 30, which is 0.5.
Constraints
1 <= len(prices) <= 801 <= close <= 500
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More pandas problems
- Department HeadcountMedium
- Earning More Than the ManagerMedium
- Employee BonusMedium
- Employee DepartmentsMedium
- Find Valid EmailsMedium
- First Time Below ZeroMedium
- Last Person on the BusMedium
- Manager NamesMedium