Skip to main content
Question

Trying to apply a max number + row number into a new attribute field.


I have a dataset from a spreadsheet that i have created a counter for each row successfully.

imageThe SQL table i am importing this dataset into has a primary key (highlighted). This primary key is not recorded anywhere in the database as a sequence number. 

imageI have added in a statisticsCaculator transformer to obtain the max number.

image 

I want to insert each row from my dataset (first screenshot) but i want to insert the LUPID as count + LUPID.max. so i end up with 1691+1 = 1692, 1691+2 = 1693, 1691+3 = 1694 etc for each row

 

what transformer would i use to do this?

 

 

2 replies

nielsgerrits
VIP
Forum|alt.badge.img+55

You can do this using an AttributeCreator or AttributeManager by using the value

@Evaluate(@Value(_count)+@Value(LUPID.max))

You can do this using the GUI by clicking the arrow in the Attribute Value field and choose "Open Arithmetic Editor..."


  • November 10, 2023

It sounds like you're trying to create a new attribute field in your dataset, where the values are derived from the sum of the maximum number in a specific column and the row number for each record. Here's a general guide on how you can achieve this using Python in a tool like pandas:

import pandas as pd

 

# Assuming you have a DataFrame named 'df' and a column named 'your_column'

# Replace 'your_column' with the actual column name in your dataset

 

# Calculate the maximum value in the specified column

max_value = df['your_column'].max()

 

# Create a new attribute field by summing the max value and the row number

df['new_attribute'] = max_value + df.index + 1

 

# If your dataset doesn't have a default index, you might need to reset it

# df.reset_index(drop=True, inplace=True)

 

# Display the updated DataFrame

print(df)

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings