I have two numpy arrays of the following shapes, and I need to extract values from a 3D array using stored indices from a 2D one: vals = (65, 65, 3500) This contains 3500 values that were calculated in a 65×65 grid, from which I need to extract values indices = (65, 65) This contains the indices of the minimum
Category: Questions
Python Web Scraping – How to Skip Over Missing Entries?
I am working on a project that involves analyzing the text of political emails from this website: https://politicalemails.org/. I am attempting to scrape all the emails using BeautifulSoup and pandas. I have a working chunk right here: The above results in pulling the data I want. However, I want to loop through larger chunks of the emails in this archive.
Python: How to explode column of dictionaries into columns with matching keys?
I have a column in pandas dataframe that has the following structure (see example). I think I have a nested dictionary in a single column, and I want each key to have it’s own column. I want all the matching keys to be the same column. Run the examples for more details I want to explode the dataframe so that
Regex removes certain words from my string – Python
The below code is to lookup a dictionary and replace string with values corresponding to dict’s key. Can someone help me understand why my code omits certain words? It removes lh preceeded and followed with a . i.e., lh. and .lh. How to overcome this? I get the output left hand l.h. -left hand- l.h plh phli lhp 1lh lh1
How to send a file with telegram bot in python
I´m trying to send a file using the code below which results in the following error: ValueError: too many values to unpack (expected 2) How can I fix this? Answer try this one:
Python get request: ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED]
I’m trying a simple Python get request but failing. As described here, I should be able to: But instead I get I’m running a script from a Windows command prompt. Is it perhaps because I’m behind a company firewall? Answer The quickest fix is setting verify=False: Posibly duplicate https://stackoverflow.com/a/12864892/8473136
Some letters are not getting counted in the below code in Python
I am trying to write a code to count letters in a string and store them as key value pair in a separate dictionary with key as the letter and value as the total count of that respective letter. Could anyone please help me out what is going wrong in the code as I am not able to debug it.
Best regex pattern to replace input function from a separate python file
I am new to regex so please explain how you got to the answer. Anyway I want to know the best way to match input function from a separate python file. For example: match.py Now I want to match ONLY the input statement and replace it with a random number. I will do this in a separate file main.py. So
Decode UUID 4 as a Python string
I would like to generate a UUID v4 string starting from the uuid import from the Python standard library. I know I can cast a UUID to str by doing str(uuid.uuid4()), however I am trying to understand what the bytes in that class instance mean. While trying to decode those bytes I see all sorts of errors, either the string
how to iterate over a strict list of files with python to make a tar of them
using python3 (in a venv) I am looking for a way to save some files, each strictly defined as its own full pathname in a variable I would do something looking like this: but I get errors about : I’m still new to python, so can you help define why and how I can fix that (method, syntax ?) Answer