Creating an attribute with reference values from another ExampleSet
Hi, everyone.
I'm stucked some days with the creation of an attriibute that must be filled with the values from another example set, result from an aggregation operation. There is a "CNPJ" attribute on the main example set, that has it's values repeated over the 25.000+ rows. The aggregation set is made of 700+ rows of unique CNPJ values and a second collumn with it's counts ([count(CNPJ)]). What I need is to create a collumn with the count(CNPJ) value on every time the sameCNPJ appears on the main set.
The better way I found until now is Python Scripting, that is fully working. I made them be read through:
I'm stucked some days with the creation of an attriibute that must be filled with the values from another example set, result from an aggregation operation. There is a "CNPJ" attribute on the main example set, that has it's values repeated over the 25.000+ rows. The aggregation set is made of 700+ rows of unique CNPJ values and a second collumn with it's counts ([count(CNPJ)]). What I need is to create a collumn with the count(CNPJ) value on every time the sameCNPJ appears on the main set.
The better way I found until now is Python Scripting, that is fully working. I made them be read through:
<div>import pandas</div><div><br></div><div>def rm_main(cnpj, data): # cnpj is the aggregation set and data is the sain set</div> # code<span> return data</span>But already tried with these codes and all fail:
import pandas
def rm_main(cnpj, data):
data["CNPJ_count"] = [cnpj["count(CNPJ)"] for
data["CNPJ"] = cnpj["CNPJ"] in data["CNPJ"]]
return dataimport pandas
def rm_main(cnpj, data):
CNPJ_count = []
for count in data["CNPJ"]:
if data["CNPJ"] == cnpj["CNPJ"]:
CNPJ_count.append(cnpj["count(CNPJ)"])
data["CNPJ_count"] = CNPJ_count
return data
Anyone could help?