Skip to content

Tag: python

How to append a dictionary with multiple keys to a dataframe

I am trying to append a dictionary to my DataFrame. This is how the DataFrame looks: And this is the dictionary: I need to append this dictionary to my df. I know how to do it when I append one column (using map) but this is not going to work here. Any ideas on how to append this? Answer You

Marking an email as read python

I’d like to mark an email as read from my python code. I’m using to get access to the account. This part works great. I then get into my desired folder using this Again, this works great. This is where marking it as read seems to not work. I’ve tried the tips and answers from this post Mark …

Reddit isn’t scraping the top comments (python/selenium)

Put the entire code into a question, thank you to all that have replied but this issue is super annoying either way help is appreciated! Context: This code is meant to go onto the top reddit post of the day/week, then screenshot it and once that’s done it goes to the comments and screenshots the top com…

Getting MacOS process id from user using python

I want to get the pid by passing in the user name. For example, in the picture of a macOS activity monitor, the user name is ‘root’, and I want something that can return all running processes under user name ‘root’. Answer Use psutil.process_iter() to get all running processes, and the…

How to fill in missing center of a 2d gaussian

I have a 2d gaussian whose center has been destroyed by pixel saturation. I need the center to be filled in because a poorly filled in center will confuse a neural network I’m trying to train. See below: The scattered nan values I can handle fairly easily, but the large cluster in the gaussian’s c…

Trying to sum numbers between numbers more efficiently

TLDR: Need to make code below more efficient. I’m trying to solve a coding challenge that requires I sum all numbers between two numbers. My code shown below is passing the tests but is taking too long to run, causing me to fail due to a time out. Is there any way to rewrite this to do the same thing