data:pandas:allign
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| data:pandas:allign [2018/03/24 13:15] – created aistis | data:pandas:allign [2018/04/03 20:45] (current) – aistis | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | you can join objects if they have same type axis | + | allign data in DataFrame |
| + | <code python> | ||
| + | #allign data to dataframe | ||
| + | df1 = pd.DataFrame(0.0, | ||
| + | start = time.time() | ||
| + | for q in d: | ||
| + | df1.iloc[np.in1d(all_date, | ||
| + | | ||
| + | print (" | ||
| + | </ | ||
| + | |||
| + | |||
| + | allign data in numpy array (3x faster) | ||
| + | <code python> | ||
| + | # allign using numpy | ||
| + | start = time.time() | ||
| + | a1 = np.zeros((len(d), | ||
| + | i = 0 | ||
| + | for q in d: | ||
| + | idx = np.in1d(all_date, | ||
| + | a1[i, idx] = q.pnl | ||
| + | i = i + 1 | ||
| + | print (" | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | you can join/ | ||
| + | |||
| + | for example align two time series by date | ||
| {{: | {{: | ||
| + | |||
| + | {{: | ||
data/pandas/allign.1521890115.txt.gz · Last modified: by aistis
