0% found this document useful (0 votes)
13 views7 pages

Python

Uploaded by

asce.luffy.soba
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views7 pages

Python

Uploaded by

asce.luffy.soba
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

1. Click on "Transform data" button from home tab .

Once you click on this button Power Query


Editor page will get open

2. Click "Enter Data" option from tab.After click on Enter data option create one blank table and
rename table name as "combined_data" then click on ok button

Change “table” to "combined_data"


3. Activate the new table i.e “combined_data”. Go to the Transform tab and click Run Python
Script. This will open the Run Python Script editor.click on ok button.

4. Activate the formula bar and replace what's in it with “=


Python.Execute("# Python:",[df1=data, df2=izo_ref])”
5. Go to the Transform tab and click Run Python Script. This will open the Run Python Script editor.
Insert the following code snippet.
Note:Please change file path which are highlighted in below code .

#Python:
import pandas as pd
df2=df2.rename(columns={"Link Delivered Date":"Link Delivered Date_izo","TCL Status":"TCL
Status_izo","PO No":"PO No_izo"})
df3 = pd.merge(df1, df2, how = 'outer',on="Final Unique id")
required_data=df3 [["Final Unique id","Unique ID","SubStatus","PM Name","Cust_Name","TCL
Status","TCL Status_izo","City","State","BW","Supplier ARC in Inr","Supplier OTC in
INR","Management Status","Management Substatus","Commissioned Ageing","Commissioned
Slab","Tata Comm Feasibility ID","Store Code","Cust_Name","MRC (in USD)","NRC (in
USD)","Installation address","COF Date","Order Login Date","PO No","PO Date","Final Goahead
Date","Link Delivered Date","IZO Provider Name","MRC (INR)","NRC (INR)","SFDC Optimus
Status","IZO Provider Name","First Provider Name(during order login)","Second Provider
Name","Third Provider name"]] # add column header here
required_data.to_csv(r"C:\Users\Kanandha\Documents\ pricing_data.csv",index=False)
#add your local machine path in highlighted part
import paramiko #used for server connection and upload
import os
from datetime import datetime
from os.path import getsize
os.chdir(r"C:\Users\Kanandha\Documents")
import sys
ip='115.114.71.53'
po=22
user='kavitha'
pass1= 'dev0P0werB$'
ssh_client=paramiko.SSHClient() #creating instance of Paramiko SSH Client
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) #to validate the trust with
machine
ssh_client.connect(ip,port=po,username=user,password=pass1)
sftp = ssh_client.open_sftp() #create object of SFTP which helps for file transfercurrent_month_text
= datetime.now().strftime('%h')
path = "pricing_data.csv"
localpath =r"C:\Users\Kanandha\Documents\ pricing_data.csv"
#add your local machine path in highlighted part where you have saved “pricing_data.csv” file
sftp.put(localpath, path)
6. After selecting OK, Power Query Editor displays a warning about data
privacy For the Python scripts to work properly in the Power BI service, all
data sources need to be set to public or organizational

7. Apply this changes and save workspace.

8. Schedule refresh steps:


a. Schedule refresh for this workspace as per your convenience

b. Add gateway connection


c. In “data source credentials” add credential for python under dataset tab(Datasets->Data
source credentialsà Edit credentialsàSign in)(Important step)

d. If sign in is done successfully then below popup will come


e. Schedule refresh as per your convenience.

You might also like