Using Script_REAL function for crosstab(pivot_table) result

385 Views Asked by At

I am trying to make a pivot_table(crostab) calculation and find the result

In Python, my data-frame variables are like this

pd.crosstab(columns=df['user'],index=df['date'],values=df['latest_balance'], aggfunc='sum').ffill().sum(axis=1).reset_index()

and result:

enter image description here

when I add into tableau like this:

SCRIPT_REAL("
import pandas as pd 
import numpy as np


pd.crosstab(columns=_arg1,index=_arg2,values=_arg3, aggfunc='sum').ffill().sum(axis=1)




",
ATTR([user]),
ATTR([date]),
ATTR([latest_balance]) )

I am getting:

Error processing script
ValueError : If using all scalar values, you must pass an index

I am pretty new python with tableau so sorry if it is a silly question.

0

There are 0 best solutions below