function

Trying to avoid Globals in Python Functions

Trying to avoid Globals in Python Functions Question: I’m still munching through learning the ins and outs of Python3 through multiple sources (books like LPTHW and online resources) and I like to mash up everything I have learned in some of the tasks… only this one has me stumped as I come from a limited …

Total answers: 1

how to exit exec() like in a function in Python

how to exit exec() like in a function in Python Question: I’m currently trying to make an self-modifying algorithm in Python. To do that, i have a string containing an algorithm that i run using the exec(algorithm) function inside another funciton. the algorithm that i want to run looks like this : if (a): do_something() …

Total answers: 1

Creating labels based on partial string matches in Python

Creating labels based on partial string matches in Python Question: I have an index column that’s leading 2 or 3 characters indicating a category I’d like to create labels for. Consider the following data: Index NDP2207342 OC22178098 SD88730948 OC39002847 PTP9983930 NDP9110876 with a desired output of: Index Labels NDP2207342 NCAR OC22178098 OCAR SD88730948 SDAR OC39002847 …

Total answers: 2

Transforming lists in rows dataframe to strings

Transforming lists in rows dataframe to strings Question: I have a dataset that has a column that has its values stored in lists. I want to transform the lists into strings, i.e. the values will go from [a, b, c] to "a b c" separated by spaces, in the same column. I was able to …

Total answers: 1

Amend string / URL and iterate through list

Amend string / URL and iterate through list Question: I’m looking to scrape a certain table where the link is amendable with a certain year and week. URL = https://www.debestseller60.nl/200511#top I have two lists; one having years ranging between 2005 and now and one having all the week numbers in a year. years = list(range(2005, …

Total answers: 2

Python OpenCV documentation

Python OpenCV documentation Question: Original question for posterity below I understood that functions are technically only in C++ and only the wrapper is available in Python with function calls examples in the documentation. It’s quite possible that, for those who are just starting out with OpenCV, the concept may not be as simple and intuitive …

Total answers: 2

Python – Having issues getting my function to loop through items in my list

Python – Having issues getting my function to loop through items in my list Question: Can someone help me and explain where I am going wrong with this code please? I am working through the Python Crash Course and have tried to modify a program that greets users from a list.The issues is the output …

Total answers: 2