Hi all,
I am working on clinical data where I need to calculate sessions for patients by calculating date difference. I can do the same in python but the same script when used in power bi’s power query it gives error as below
DataSource.Error: ADO.NET: Python script error.
TypeError: unsupported operand type(s) for -: ‘str’ and ‘str’
Details:
DataSourceKind=Python
DataSourcePath=Python
Message=Python script error.
TypeError: unsupported operand type(s) for -: ‘str’ and ‘str’
ErrorCode=-2147467259
Script used by me is :-
‘dataset’ holds the input data for this script
import pandas as pd
import numpy as np
import datetime
dataset[‘Days_btw’] = dataset.groupby(‘NetSuiteId’)[‘session_date’].diff() / np.timedelta64(1, ‘D’)
This is link for data and pbix file
Expected output is as below which I got in python
Or is there any other way I can do this differently because I am importing this data from our production database.
Thank You.