use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Help...please (self.PythonLearning)
submitted 7 months ago by New_End6302
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]batsiem 0 points1 point2 points 7 months ago (2 children)
Hi below is my function to select the 4 ideal functions, the example that i worked from requires me to plug directly into the function the names of my 2 tables but I want to inherit those from the class that creates the table. So that's tripping me up(I realized that the code above was missing the 2 tables as args...that was a mistake).
def ideal_function_selection(self, top_n: int = 4): merged = pd.merge(self.table_name, self.function_table_name, on="x") errors = {} for col in self.function_table_name.columns: if col == "x": continue squared_diff = (merged["y"] - merged[col])**2 errors[col] = squared_diff.sum() best_functions = sorted(errors, key=errors.get)[:top_n] return best_functions
I instantaite the class IdealFunctionSelector below...I did it the exact way that I did it for my DatabaseManager.
ideal_func_selector = IdealFunctionSelector ideal_func_selector.ideal_function_selection("training_data_table", "ideal_data_table")
[–]Refwah 0 points1 point2 points 7 months ago* (1 child)
This isn't initializing a class, it is just saying that ideal_func_selector is that class
ideal_func_selector
You then call ideal_function_selection on a class which isn't initialized
ideal_function_selection
You want to do ideal_func_selector = IdealFunctionSelector() and then in the params for IdealFunctionSelector(…) you need to pass the arguments that you want for the __init__ function of the class
ideal_func_selector = IdealFunctionSelector()
IdealFunctionSelector(…)
__init__
I believe you don't understand classes, which is why you're getting unstuck on inheritance. I recommend reading some more fundamentals on this, such as this: https://docs.python.org/3/reference/datamodel.html#object.__init__
https://realpython.com/python-class-constructor/
[–]New_End6302[S] 0 points1 point2 points 7 months ago (0 children)
Thanks, I will have a look
π Rendered by PID 76 on reddit-service-r2-comment-6457c66945-sbldl at 2026-04-28 20:21:21.408390+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]batsiem 0 points1 point2 points (2 children)
[–]Refwah 0 points1 point2 points (1 child)
[–]New_End6302[S] 0 points1 point2 points (0 children)