Posts by Leonardo Borges • 171 points
8 posts
-
1
votes2
answers577
viewsA: Group three commands into one
Roger, I understand that it is impossible for you to group the three commands the way you want. That’s because from the moment you use groupby, it returns a new Dataframe (DF) with another…
-
5
votes2
answers3465
viewsA: How to invert the order of columns of a Dataframe with Python
Suppose the column names of your Dataframe (DF) are "fruit", "vitamin" and "price" in that order. You can reorder it as follows: df = df[['preço', 'vitamina', 'fruta']] I mean, you need to pass one…
-
0
votes1
answer79
viewsA: Help me syntax my FOR repeat code
So I’m going to give you 2 approaches to solving the problem. The first is to follow your logic, iterating over a dataframe. The second is using some of the pandas' own methods. Lets go! Dataframe…
-
0
votes1
answer256
viewsA: Creating decency function
Hello fellow Pythonist! I’ve put together a solution proposal for your problem. Decndium Function I believe that you have chosen a suitable path, create a function that calculates the decndium. And…
pythonanswered Leonardo Borges 171 -
0
votes1
answer143
viewsA: Wrong answer and I don’t know why in Python
Check your counter. You set it to "cont1 = 0" but use "cont += 1". Define it as cont = 0, keeping the same nomenclature of the variable that will work. Hug and good studies.
pythonanswered Leonardo Borges 171 -
1
votes1
answer290
viewsA: groupby - add according to criteria
Question Hello Roger, to solve it is simple, we just have to think about the logic of chaining pandas to perform correctly. If you want to add (total) the Cpfs (aggregates) with values higher than…
pandasanswered Leonardo Borges 171 -
2
votes1
answer2305
viewsA: Add new data in an empty pandas dataframe
It seems simple to solve. Assuming you have scanned all your files and inserted all the lines into the Dataframe. Just use the code: df.groupby(df.index).sum() Example import pandas as pd import…
-
2
votes1
answer100
viewsA: calculate area and print it in another txt file in python
Problem Hello Matheus, from what I understand you want to create a new file by inserting a new column using the parameters of its geometric shape. If it is a 'square', you multiply the second…
pythonanswered Leonardo Borges 171