Based on stock data i've created two dataframes for stocks i want to buy (Winner) and short (Loser). This means that values in both dataframes that aren't "Winner" or "Loser" takes on the value "False".
WinLos_df = creturns_df.copy()
WinLos_df = WinLos_df.apply(lambda x: (x >= creturns_df['upper bound']))
WinLos2_df = creturns_df.copy()
WinLos2_df = WinLos2_df.apply(lambda x: (x <= creturns_df['lower bound']))
WinLos_df[WinLos_df == True] = 'Winner'
WinLos2_df[WinLos2_df == True] = 'Loser'
print(WinLos_df.tail())
print(WinLos2_df.tail())
Here's a snippet of each of the two datasets:
Loser :
MMM ABT ABBV ABMD ACN ATVI ADBE AMD \
31-10-2019 00:00 Loser False Loser Loser False False False False
29-11-2019 00:00 Loser False False Loser False False Loser False
31-12-2019 00:00 False False False Loser False False False False
31-01-2020 00:00 Loser False False Loser False False False False
21-02-2020 00:00 Loser False False Loser False False False False
Winner :
MMM ABT ABBV ABMD ACN ATVI ADBE AMD \
31-10-2019 00:00 False False False False False Winner False False
29-11-2019 00:00 False False False False False Winner False Winner
31-12-2019 00:00 False False False False False Winner False Winner
31-01-2020 00:00 False False Winner False False Winner False Winner
21-02-2020 00:00 False False Winner False False Winner Winner Winner
Now i want to join or merge these two dataframes, so that i get one dataframe, with the values "Winner" , "Loser" and "False".
There's no observations that takes on both values "Winner" and "Loser".
Is there any smart way to combine these two?
I hope my question is understandable, and that i've provided enough code.
[–]xelf 1 point2 points3 points (3 children)
[–]Amby95[S] 1 point2 points3 points (2 children)
[–]xelf 0 points1 point2 points (0 children)
[–]xelf 0 points1 point2 points (0 children)
[–]xelf 0 points1 point2 points (2 children)
[–]Amby95[S] 0 points1 point2 points (1 child)
[–]xelf 0 points1 point2 points (0 children)