🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Use python to read several Rapidminer ExampleSets

User: "frasau"
New Altair Community Member
Updated by Jocelyn
Hi everyone!
I am a beginner of Rapidminer.

I created a Loop on rapidminer that reads a series of csv files from a folder on my pc.
The loaded ExampleSets have only two columns.
For only one of these columns I want to calculate the larger values with Python.

how can this be done?

For the moment I have written a code on Python that reads ONLY A csv file of these:

with open(r'C:\Users\FR\Desktop\First.csv') as file:
    for line in file:

        item = int(line)

        list.append(item)


results = []


for i in range(len(list):
 
    a = lista[i-1]

    b = lista[i]

    c = lista[i+1]

    if b >= a and b >= c:

        results.append(b)

print(results)

is there a way not to repeat this code for each file?

Find more posts tagged with

Sort by:
1 - 2 of 21
    User: "btamas"
    New Altair Community Member
    Updated by btamas
    Hi frasau,

    If you would post your process here, maybe someone could give you more specific advise. Just copy the process xml into the post. If you are not using the Execute Python operator from the Python Scripting Extension, I highly recommend to use that. With the Execute Python operator you can work on pandas DataFrame. You have to define an rm_main method in your code as well. Something like this should do the trick:

    import pandas<br>def rm_main(df):<br>&nbsp; &nbsp; df["c"] = df.apply(lambda x: x["a"] if x["a"] > x["b"] else x["b"], axis=1)<br>&nbsp; &nbsp; return df


    Hope this helps!
    User: "frasau"
    New Altair Community Member
    OP
    thank you very much @btamas !!!!