This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
random.random() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
random.seed(0) | |
random.randint(0,9) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
random_number = random.randint(0,9) | |
clients.loc[clients['client_id'] == random_number] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
clients = pd.DataFrame() | |
clients['client_id'] = [0,1,2,3,4,5,6,7,8,9] | |
clients['client_name'] = ["Mobili Ltd.","Tymy Ltd.", "Lukas Ltd.","Brod Ltd.", | |
"Missyda Ltd.", "Abiti Ltd.", "Bomy Ltd." , "Citiwi Ltd.", "Dolphy Ltd.", "Doper Ltd."] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Basic candlestick graph created with Python engine: | |
```{python,warning=FALSE} | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import datetime | |
from mpl_finance import candlestick_ohlc | |
import matplotlib.dates as mdates | |
ax = plt.subplot() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Now let's work with Python pandas data frame inside R : | |
```{python} | |
import matplotlib.dates as mdates | |
py_data_frame = r.data | |
py_data_frame['Date']=py_data_frame['datetime'].map(mdates.datestr2num) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Let's prepare the data with R: | |
```{r data_load} | |
library(reticulate) | |
data = read.csv("15m.csv",stringsAsFactors = FALSE) | |
colnames(data)[1]<- "datetime" | |
head(data) | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Basic candlestick graph created with R engine: | |
```{r visualize_python_data} | |
r_data_frame %>% | |
plot_ly(x = ~datetime, type="candlestick", | |
open = ~Open, close = ~Close, | |
high = ~High, low = ~Low) | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Now let's work with Python pandas data frame inside R : | |
```{r check_python_data,include=FALSE} | |
library(reticulate) | |
library(plotly) | |
r_data_frame <- py$data | |
head(r_data_frame) | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Let's prepare the data with Python: | |
```{python data_load} | |
import pandas as pd | |
data = pd.read_csv("15m.csv") | |
data.rename(columns={"Unnamed: 0": "datetime"},inplace=True) | |
data.head() | |
``` |