Forum Discussion
WilliamHill99
5 months agoRegular Visitor
Python in Power Query VS Code
Hi All, I would like to fetch/ read csv file from local machine and performs pivot function in Python in PowerQuery. I tested my code in VScode and result is fine and expected as it is, but it ...
- 5 months ago
py script
import pandas as pd import numpy as np df['DATE_ID'] = pd.to_datetime(df['DATE_ID']) df['Town-Citycode'] = df['Town-Citycode'].str[:9] df = df.sort_values(['Town-Citycode', 'DATE_ID']) df['diff'] = np.where(df.groupby('Town-Citycode')['SALECOUNT'].diff()>0, 'Up', 'Down') pvt = df.pivot_table(columns=['DATE_ID'], index=['Town-Citycode'], values=['SALECOUNT', 'diff'], aggfunc='sum') pvt.reset_index(inplace=True)When it comes to data visualization, DAX is often a more elegant alternative,
v-sgandrathi
Community Support
5 months agoHi WilliamHill99,
Thank you ThxAlot and lbendlin for your responses to the query.
Following up to check whether you got a chance to review the suggestions given. If the issue still persists please let us know. Glad to help.
Thank you.