Hi,
How to display specified data in new column when the row appear certain data in dashtable.
Ex:
Merchant ID
Title
Information
Acc01
Product
Clothes
Acc01
Customer
Customer12
Acc01
Sale date
01/10/2022
Need to add a new column to tag the sale reference number.
Expected output:
Merchant ID
Title
Information
New column
Acc01
Product
Clothes
Acc01
Customer
Customer12
Acc01
Sale date
01/10/2022
sale no 12345
Hello @beginof ,
In order to add both a column and row information for that column, your callback would have to output both columns and data.
Hi @jinnyzor ,
Actually, my original data is as per below:
Merchant ID
Product
Customer
Sale date
Sale no
Acc01
Clothes
Customer12
01/10/2022
sale no 12345
The data as I shown previously which is already transpose
.
Merchant ID
Title
Information
Acc01
Product
Clothes
Acc01
Customer
Customer12
Acc01
Sale date
01/10/2022
Code:
transpose = dff.melt(id_vars = ['Merchant ID']
,var_name = ['Title']
,value_name = 'Information')
So, based on the code, how can I add the sale no 12345
into the New column
and only for the ow of Sale sate
?
When is the sale no supposed to be added, before or after it is displayed to the user?
I was assuming you were adding the column through interaction with the datatable, is that correct?
Sorry, I can’t get what you means.
Require to let the system auto-detect the Title
column when the row data is Sale date
and there is no empty in the Information
, so it will add the sale no 12345
into the Sale no
column for the Sale date
row.
Other than that will be blank.
Currently, I’m using the merge
function to get the data. However, it look like if I has more than one condition for the Sale no
column, this method look like not working. For example, I want to add-in a new data called refer to profile
in the Sale no
column when the row Title = Customer
transpose = dff.melt(id_vars = ['Merchant ID']
,var_name = ['Title']
,value_name = 'Information')
tr = transpose[transpose['header'] == 'Sale date' ]
tr['Sale no'] = transpose['Sale no']
final_df1 = pd.merge(left = transpose,right = tr, how="left", left_on=['Merchant ID', 'header', 'info'], right_on=['Merchant ID', 'header', 'info'])
beginof
November 14, 2022, 7:41am
6
How to insert the data into the field like the logic below:
if
columnA = ‘abc’, then columnB = ‘123’
elif
columnA = ‘cde’, then columnB = ‘567’
else
columnB = ‘’
This is what I need in my new table.