shadowing

Python TypeError: 'tuple' object is not callable when using list comprehension inside for loop

Python TypeError: 'tuple' object is not callable when using list comprehension inside for loop Question: I’m trying to generate a list of strings using a list comprehension, where the string is formatted using f-strings: features = [("month", (1, 12)), ("day_of_year", (1, 365))] for feature, range in features: cols= [f"transformed_{feature}_period_{i:02d}" for i in range(12)] If I …

Total answers: 2

How to get this json data using Python and put into pandas dataframe?

How to get this json data using Python and put into pandas dataframe? Question: I am trying to get a JSON data every 1-minute using python and put it into pandas dataframe. The issue is only I am getting the data only the first time and then I am getting errors(Retrying). The code is here: …

Total answers: 1

Importing installed package from script raises "AttributeError: module has no attribute" or "ImportError: cannot import name"

Importing installed package from script with the same name raises "AttributeError: module has no attribute" or an ImportError or NameError Question: I have a script named requests.py that needs to use the third-party requests package. The script either can’t import the package, or can’t access its functionality. Why isn’t this working, and how do I …

Total answers: 2

What is the problem with shadowing names defined in outer scopes?

What is the problem with shadowing names defined in outer scopes? Question: I just switched to PyCharm and I am very happy about all the warnings and hints it provides me to improve my code. Except for this one which I don’t understand: This inspection detects shadowing names defined in outer scopes. I know it …

Total answers: 10