1 | import pandas as pd |
---|---|
2 | def iterate(col): |
3 | prev = 0; |
4 | res = 0; |
5 | val = 0; |
6 | for curr in col: |
7 | if curr – prev > 0: |
8 | res += 1; |
9 | else: |
10 | res = 0; |
11 | prev = curr; |
12 | if val < res: |
13 | val = res; |
14 | return val; |
15 | data = pd.read_excel('D:/Stock.xlsx',sheet_name=0). sort_values('tradeDate').groupby('Company')['closePrice'].apply(iterate); |
1 | select max(continuousDays)-1 |
---|---|
2 | from (select count(*) continuousDays |
3 | from (select sum(changeSign) over(order by tradeDate) unRiseDays |
4 | from (select tradeDate, |
5 | case when closePrice>lag(closePrice) over(order by tradeDate) |
6 | then 0 else 1 end changeSign |
7 | from stock) ) |
8 | group by unRiseDays) |
A | |
---|---|
1 | =stock.sort(tradeDate) |
2 | =0 |
3 | =A1.max(A2=if(closePrice>closePrice[-1],A2+1,0)) |
Vertica does not support stored procedures. Complex business logic can only be written in Java. Long code is hard to maintain.
There are 44 kinds of Excel, which are parsed by Java and imported into database. The development cycle is long and hard coding is difficult.
All 44 kinds of Excel analysis reduced from 32 person days to 6 person days
Each Excel parsing code changed from 100 lines to 3 lines
In addition to the short code and easy maintenance, script hot deployment takes effect immediately after modification