I’m generating documentation with Sphinx for project with structure like this : I want to exclude tests, and workflow/definition from documentation. I tried exclude pattern in docs/conf.py But even though workflow/definitions are still automatically generated. Could someone show me correct exclude patte…
ModuleNotFoundError: No module named ‘selenium’
I get an error while running this selenium script. Please suggest what can be done to fix this: Script: Error: Traceback (most recent call last): File “C:/Users/admin/Desktop/test2.py”, line 2, in from selenium import webdriver ModuleNotFoundError: No module named ‘selenium’ I have ins…
Webscraping a particular element of html
I’m having trouble scraping information from government travel advice websites for a research project I’m doing on Python. I’ve picked the Turkey page but the logic could extend to any country. The site is “https://www.gov.uk/foreign-travel-advice/turkey/safety-and-security” The code I’m usi…
Add datashader image to matplotlib subplots
Is it possible to add a datashader image to a set of matplotlib subplots? As a concrete example, Where I have a two by two array of matplotlib subplots and would like to replace the [0,0] plot ax_r[0] in the above example with the datashader image a. Is this possible, and if so, how? Thanks! Answer Update [Ja…
Replacing values greater than a number in pandas dataframe
I have a large dataframe which looks as: I want to replace each element greater than 9 with 11. So, the desired output for above example is: Edit: My actual dataframe has about 20,000 rows and each row has list of size 2000. Is there a way to use numpy.minimum function for each row? I assume that it will be
Relative imports – ModuleNotFoundError: No module named x
This is the first time I’ve really sat down and tried python 3, and seem to be failing miserably. I have the following two files: test.py config.py config.py has a few functions defined in it as well as a few variables. I’ve stripped it down to the following: config.py test.py I also have an __ini…
re.sub erroring with “Expected string or bytes-like object”
I have read multiple posts regarding this error, but I still can’t figure it out. When I try to loop through my function: Here is the error: Answer As you stated in the comments, some of the values appeared to be floats, not strings. You will need to change it to strings before passing it to re.sub. The…
How to get the latest frame from capture device (camera) in opencv
I want to connect to a camera, and only capture a frame when an event happens (e.g. keypress). A simplified version of what I’d like to do is this: However, cap.read seems to only capture the next frame in the queue, and not the latest. I did a lot of searching online, and there seems to be a lot of
Extracting values from .dat file in python
I have a file which is having pipe delimiter and wanted to convert delimiter from | to ^A Source file has data in key:Value pair. For eg. in the below given file SSLPROTOCOL is the Key and TLSv1.2 is value. I was looking for only the value with delimiter in the target file. Please sugesst Output: I want value…
Accessing configuration parameters passed to Airflow through CLI
I am trying to pass the following configuration parameters to Airflow CLI while triggering a dag run. Following is the trigger_dag command I am using. My problem is that how can I access the con parameters passed inside an operator in the dag run. Answer This is probably a continuation of the answer provided …