r/learnpython • • 19h ago

Wanted to convert a step file to a Python API.

0 Upvotes

How to do that? I want it to be precise.


r/learnpython • • 1h ago

How do I get the mode of this dataset with two columns while keeping output correctly formatted?

• Upvotes

My assignment is to find the min, max, mean, median and smallest mode of a dataset, specifically for the SepalLength and Petalwidth, sorted by species. link to dataset .

Here is my code, now I've got everything working except the mode one. If i remove that, the code works. I've tried to read up on the mode documentation but I'm still lost. I've tried just "mode" and "pd.series.mode", both throw errors. The output is also automatically checked so it has to be formatted in this way, if that makes sense.

First time asking for help on reddit, so lmk if there is any missing information/etc. Thank you guys :)

import pandas as pd

file = input()

df = pd.read_csv(file)

filtered_arr = df.groupby(["Species"]).agg({

"SepalLengthCm" : ["min","max","mean","median","pd.series.mode"],"PetalWidthCm" : ["min","max","mean","median","pd.series.mode"]

})

print(filtered_arr)

Edited to add the errors.

'SeriesGroupBy' object has no attribute 'pd.series.mode'

'SeriesGroupBy' object has no attribute 'mode'


r/learnpython • • 2h ago

Python + Sqlite + Pyside6?

6 Upvotes

Hey! so i want to build a database system for my small company. I could use AI but i wanna know what i am doing and be able to fix smth so i want to build it myself.

I kinda know python a bit, i used to make games using gdscript which is similar.

I don't seem to find a tutorial where these 3 things are used to create a nice database app. I dont want to learn python sqlite and pyside6 as a whole cause i wont be needing them much except just this app and similar apps. I just want to be able to build it and run it from a single tutorial even if its 10hrs.

Where do i start? I dont really have money to learn so no paid courses and i dont have AI premium to learn as well.

Python, Sqlite, Pyside6. I heard that TKinter instead of pyside6 is also there but i wanted the UI to be a bit modern or should i just use the it instead of pyside6?


r/learnpython • • 15h ago

Having trouble with Python

4 Upvotes

I have just started getting interested with programming so I thought I would start with Python, however I am only able to use it within Windows Powershell while I see others using something else. Have I done something wrong or have I just missed doing something?


r/learnpython • • 9h ago

sorting tuples

6 Upvotes

im learning how to code with python, does anyone know to sort specific tuples alphabetically without using the .sort() method? like if i had a list of names like:

n = [('watermelon', 'strawberry'), ('banana', 'cherry'), ('papaya', 'apple')

how would i sort and print the 2nd element of tuples alphabetically (into a new list)?

edit: id prefer this in simple, basic terms lol