I am dynamically importing files/modules using import_module. When I had the files in the same directory this worked: However, when I reorganized my folder structure to look this: I assumed that I could do this: But it gives me the error ModuleNotFoundError: No module named ‘child’ I tried the fol…
Tag: python
AttributeError: ‘WebElement’ object has no attribute ‘select_by_value’ selecting dropdown menu using Selenium
I am trying to find menu prices for certain fast food restaurants from this website by different state. There is a dropdown menu where different states are the options. After I select a state (for example, California), I want to web scrape the different prices of their Ice Cream. However, I keep getting the s…
Datetime rolling count per category in Pandas
Starting from a DataFrame with a date and user column, I’d like to add a third count_past_5_days column to indicate the rolling count of occurrences of each row’s user during the past 5 days: date user count_past_5_days 2020-01-01 abc 1 2020-01-01 def 1 2020-01-02 abc 2 2020-01-03 abc 3 2020-01-04…
How to bind the value of a NumericProperty to the Text of a Label?
With Kivy, I understand we can use set the text of a label to a StringProperty() object, so whenever that string is updated, the label will automatically show the updated text. My minimal example code, works fine, will show “apple” then “banana” one second later: Question: How do I do …
How can I make a program to calculate the value of a continued fraction?
I am trying to make a program in Python that will calculate the value of the formula. The first 3 numbers of the continued fraction are this: To be clear I mean this: How can I write a formula in python that will calculate the sum when my input is 5? As you see in the first picture the sum
Getting “sqlite3.ProgrammingError: Incorrect number of bindings supplied” when splitting lines from file and inserting into database
I’m trying to import data from a csv file to a existing database, the database has 4 columns called product_id, Firstname, Lastname, Address and this is the code for the csv import; But I keep getting the error sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 4…
How do reduce a set of columns along another set of columns, holding all other columns?
I think this is a simple operation, but for some reason I’m not finding immediate indicators in my quick perusal of the Pandas docs. I have prototype working code below, but it seems kinda dumb IMO. I’m sure that there are much better ways to do this, and concepts to describe it. Is there a better…
Remove characters from column
I am trying to remove “0” and “:” from a column in a dataframe. The code I use is, Output: The result does not remove “0” and “:” How can I go about this? Answer You’re missing to assignment of the replacement back to the original column: Though you can ca…
Gitlab CI/CD Pipeline Runs Django Unit Tests Before Migrations
Problem I’m trying to set up a test stage in Gitlab’s CI/CD. Locally, running the unit tests goes fine and as expected. In Gitlab’s CI/CD, though, when running the script coverage run manage.py test -v 2 && coverage report the unit tests are executing before the migrations are comple…
Why does the self in the class always have the previous data?
im new to python and today i had this problem: say, i have this code incluing two classes named: slice and mat: output: I thought that: the list_mat would have 2 mat object(which is true by the output of print(len(list_mat))) And i thought every mat object in list_mat would have 4 slice objects and the var fo…