I’m trying to retrieve a list of Youtube videos from a Youtube channel, say “https://www.youtube.com/user/YouTube/videos”, to get the nth first videos (thanks to the key = “videoId”). It used to work like a charm until a few days ago, when it started to ask for my consent. I trie…
Sampling data from the pandas dataframe
I am trying to sample data from a big dataset. The dataset is like Code to generate a sample dataset The distribution of labels in the dataset is I created a new column in the dataset When I am trying to sample say 5000 items The distribution of the labels in the sampledf is not same as that in the
Python: password protect PDFs with random passwords and save file name-password
I am pretty new to Python, what I am looking for is to bulk protect a series of PDFs files within a folder, each file with a unique password randomly generated – these file name-password combinations should then be saved somewhere (potentially CSV file). Currently using a code that protects all the file…
How to replace and insert a new substring in python?
This is a working code and mabybe not very effcient code to replace a substring with another substring previously modified Input string : Output string: It has to replace substring like ‘part1’ ‘part2 an so on , with ‘PT’ and copy it between title and year substring Code: but whe…
looping through several columns and rows from csv to fill a form
Have been trying to emulate examples posted earlier, yet got stuck. I have a simple web form: Last name, name, email, password, confirm password. Also a .csv with 4 columns that corresponds to the form So, all I want is to feed the 3 entries to the form and click “Sent” after each entry. I copycat…
How do you store hobbies and personalities in a list and then generate them with a different random number to determine which hob or person you get? [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 1 year ago. Improve this question In the video game Animal Crossing: New Horizons, villagers are organized by…
pandas out of memory error after variable assignment
I have a very large pandas data frame and want to sample rows from it for modeling, and I encountered out of memory errors like this: MemoryError: Unable to allocate 6.59 GiB for an array with shape (40, 22117797) and data type float64 This error is weired since I don’t need allocate such large amount o…
Python tkinter after method not working as expected
I’m trying to learn Tkinter module, but I can’t undestand why the after method doesn’t behave as expected. From what I know, it should wait ms milliseconds and then execute the function, but in my case the function gets executed many more time, not considering the time I write. Here’s …
In python, is it better to loop and pop(0) or reverse it first and then pop()
In my code, I have two options: One is to: The other is: Both should work. But I am wondering from efficiency perspective, which approach is better? Edit I feel like I am not making this question clear. So I will paste more code here. The thing I need to do is something like below: So it actually poped in
How to test a set of values (not all) exist in a Pandas multiindex?
The isin() method applied to a Pandas index returns whether each index value is found in the passed set of values, but is there a possibility to test only a set of indexe values ? In the multiIndex below I would like to test if an index with level name s1 and level value E and level name d1 and