Forum Discussion
Python: DateTimeIndex not showing in PowerBI
- 7 years ago
Anonymous,
I can reproduce your issue, just add a statement in the button of your code like pattern below:
# 'dataset' holds the input data for this script import datetime import pandas as pd import numpy as np def datetimeix(df): df['Date\t'] = pd.DatetimeIndex(df['Date\t']) df.set_index('Date\t', inplace = True) return df df = pd.read_csv(r'C:\Users\JimmyTao\Desktop\Test.csv') dataset = dfAfter expand, the result is like this:
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous,
Could share some part of the code? Basically, the interaction between python and power bi should be like pattern below:
#dataset present the current table in power bi as input #dataset = pd.DataFrame(data, index, columns, dtype, copy) import pandas as pd completedData = dataset.fillna(method = 'backfill', inplace = False) dataset["completedValues"] = completedData[SMI missing values"] #Modify a column
Regards,
Jimmy Tao
Hi, part of the code is shown below:
import datetime
import pandas as pd
import numpy as np
import statsmodels.api as sm
def datetimeix(df):
df['Date'] = pd.DatetimeIndex(df['Date'])
df.set_index('Date', inplace = True)
return(df)
df = pd.read_csv(r'C:\Users\blai\Documents\5 year dataset.csv', encoding = "ISO-8859-1")
mthnsr = cumtotal(df)
mthnsr = datetimeix(mthnsr)
- v-yuta-msft7 years agoCommunity Support
Anonymous,
I can reproduce your issue, just add a statement in the button of your code like pattern below:
# 'dataset' holds the input data for this script import datetime import pandas as pd import numpy as np def datetimeix(df): df['Date\t'] = pd.DatetimeIndex(df['Date\t']) df.set_index('Date\t', inplace = True) return df df = pd.read_csv(r'C:\Users\JimmyTao\Desktop\Test.csv') dataset = dfAfter expand, the result is like this:
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.