Monday, April 19, 2021
Power Query - Replace Function letter fnc_replace
Friday, April 16, 2021
Power Query - Python - Load Data with (Param)
let
Source = Python.Execute("# In[0]:#(lf)import pandas as pd#(lf)import yfinance as yf#(lf)import investpy#(lf)#(lf)param="&Text.From(P_Y_N)&"#(lf)vdt_BGN = pd.to_datetime('01/01/2021')#(lf)vdt_END = pd.to_datetime('today') + pd.offsets.DateOffset(days=1)#(lf)print(""vdt_BGN:"",vdt_BGN)#(lf)print(""vdt_END:"",vdt_END)#(lf)#(lf)# In[1]:#(lf)df_Tickers = investpy.get_stocks(country='Brazil')#(lf)df_Tickers['AcaoFull'] = df_Tickers['symbol']+'.SA'#(lf)df_Tickers['AcaoName'] = df_Tickers['AcaoFull']+' - '+df_Tickers['name']#(lf)df_Tickers.sort_values(by=['symbol'], inplace=True, ascending=True)#(lf)df_Tickers.drop_duplicates('AcaoFull') #(lf)df_Tickers['IndexCol'] = range(1, len(df_Tickers) + 1)#(lf)df_Tickers#(lf)#(lf)# In[2]:#(lf)update_list = [""BRKM3"",""TWTR34"",""EBAY34"",""JNJB34""]#(lf)df_Tickers['APO'] = 1#(lf)df_Tickers.loc[df_Tickers['symbol'].isin(update_list), 'APO'] = 0#(lf)df_Tickers.sort_values(by=['APO'], inplace=True, ascending=True)#(lf)#(lf)if param == 0:#(lf) df_Tickers = df_Tickers[df_Tickers['APO'] == 0]#(lf) #(lf)df_Tickers#(lf)#(lf)# In[3]:#(lf)#datasetTEMP1 = pd.DataFrame()#(lf)#(lf)for num, t in enumerate(df_Tickers['AcaoFull'], start=1):#(lf) try: #(lf)# dataset_temp= yf.Ticker(t).history(period=""1y"")#(lf) dataset_temp= yf.Ticker(t).history(start=vdt_BGN, end=vdt_END)#(lf) dataset_temp['Acao']=t#(lf) dataset_temp['Updated']=pd.to_datetime('today')#(lf) #datasetTEMP1 = datasetTEMP1.append([dataset_temp], sort=False)#(lf) print(""{} TickerList OK: {}"".format(num, t))#(lf) except Exception as e:#(lf) print('TickerList Nok {}'.format(t))#(lf) print(getattr(e, 'message', str(e)))#(lf) #(lf)dataset = pd.DataFrame() #(lf)dataset = dataset.append([dataset_temp], sort=False)#(lf)dataset = dataset.reset_index() #(lf)dataset = dataset.set_index([dataset.index])#(lf)dataset = dataset.fillna(0) #(lf)dataset['Adj Close'] = dataset['Close']"),
dataset = Source{[Name="dataset"]}[Value],
#"Changed Type2" = Table.TransformColumnTypes(dataset,{{"Date", type datetime}, {"Open", type number}, {"High", type number}, {"Low", type number}, {"Close", type number}, {"Volume", type number}, {"Dividends", type number}, {"Stock Splits", type number}, {"Adj Close", type number}, {"Updated", type datetime}}),
#"Parsed Date" = Table.TransformColumns(#"Changed Type2",{{"Date", each Date.From(DateTimeZone.From(_)), type date}}),
// Old Dataset
StepJoin = Table.Combine({#"Parsed Date" , FAT_Tickers_TA_Old}),
#"Merged Queries" = Table.NestedJoin(StepJoin, {"Acao"}, DIM_Tickers, {".AcaoFull"}, "DIM_Tickers", JoinKind.LeftOuter),
#"Expanded DIM_Tickers" = Table.ExpandTableColumn(#"Merged Queries", "DIM_Tickers", {"IndexCol", ".AcaoFull"}, {"IndexCol", ".AcaoFull"}),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded DIM_Tickers",{{"Date", type date}, {"Open", type number}, {"High", type number}, {"Low", type number}, {"Close", type number}, {"Volume", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", ".PK_Acao_Date", each Text.PadStart([IndexCol],3,"0") & Number.ToText(Date.Year([Date])) & Number.ToText(Date.Month([Date]),"00") & Number.ToText(Date.Day([Date]),"00")),
#"Sorted Rows" = Table.Sort(#"Added Custom",{{".PK_Acao_Date", Order.Ascending}}),
#"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "IndexPK", 1, 1, Int64.Type),
FAT_Tickers_TA1 = Table.Distinct(#"Added Index", {".PK_Acao_Date"})
in
FAT_Tickers_TA1
Sunday, April 4, 2021
Python - Task Scheduler
File name (script_python.bat)
Code:
@echo off
CALL C:\Users\apo1979\Anaconda3\Scripts\activate.bat PyPWBI
C:/Users/apo1979/Anaconda3/envs/PyPWBI/python.exe "d:/.APO_OneDrive/script_python.py" runserver
pause
Sunday, March 28, 2021
Soccer Data Analysis (companies / platforms)
Short summary of Soccer Data Analysis
There are many companies / platforms, including one of the big ones:
Opta Sports
-Capture data through people who write everything down in certain games ...
-Generally there are between 1800 to 3000 observations ...
There are also other platforms that provide data, such as:
Metrica (game events)
Wyscout (game events)
https://wyscout.com/football-data-api/
SofaScore (buy Opta data)
https://corporate.sofascore.com/
Additionally, there are other very interesting ones that make predictions:
Soccer Predictions
https://projects.fivethirtyeight.com/soccer-predictions/
https://projects.fivethirtyeight.com/global-club-soccer-rankings/
Another interesting material that I started studying is from the youtube channel:
https://www.youtube.com/channel/UCUBFJYcag8j2rm_9HkrrA7w/about
All this material had great help through Matheus Evald XL7
Wednesday, February 24, 2021
DAX - Create Table JOIN / UNION
FAT_wGalaxy = UNION(
SELECTCOLUMNS(FAT_wGalaxy_R,"Data",[Data],"Valor",[Valor],"Obs",[Observacao],"Conta",[Conta],"CD",[.ReceitaDespesa],"Classe",[.Classe],"Real_Prev",[Pago_Projetado],"Status",[Status],
"Data_Pag",if(ISBLANK([Data_PAG]),[Data],[Data_PAG])),
SELECTCOLUMNS(FAT_wGalaxy_D,"Data",[Data],"Valor",[Valor],"Obs",[Observacao],"Conta",[Conta],"CD",[.ReceitaDespesa],"Classe",[.Classe],"Real_Prev",[Pago_Projetado],"Status",[Status],
"Data_Pag",if(ISBLANK([Data_PAG]),[Data],[Data_PAG]))
)
Monday, February 22, 2021
DAX - LastValue
Friday, February 19, 2021
Power Query - Sharepoint.List
let
//Errado =>
//Source = SharePoint.Tables("https://XXX.sharepoint.com/sites/XXX", [Implementation=null, ApiVersion=15]),
//Correto =>
Source = SharePoint.Tables("https://XXX.sharepoint.com/sites/XXX", [Implementation="2.0", ViewMode="All"]),
//New
// https://XXX.sharepoint.com/XXX/apprioenergy/Lists/forpostos
SharePointSite = "https://XXX.sharepoint.com/XXX/apprioenergy/",
Source = SharePoint.Tables(SharePointSite, [ApiVersion = 15]),
Navigation = Source{[Id = "818e1c12-b556-4c38-9c78-3fbc8732e848"]}[Items],
SQL - Query Analytics Basic
SELECT Nome_Produto, ROUND(MIN(Valor_Venda), 2) AS Valor_Minimo, ROUND(MAX(Valor_Venda), 2) AS Valor_Maximo, ROUND(AV...
-
There are two points to be evaluated: 1. If you want to discard the errors In this case, just run: #"Removed errors" = Table.Re...
-
Code for creating a table Dim_Calendar Refresh Path let Source = "C:\Temp\datasets\board\csv\__20200210_120926_.ARCHIVE" ...