I want to get only columns whose names start with ‘Q1’ and those starting with ‘Q3’, I know that this is possible by doing: But since my real df is too large (more than 70 variables) I search a way to get the new_df by using only desired first letters in the columns titles. My example …
Tag: python
Is there any way to get the recording url and timeline of Microsoft Teams meeting using GRAPH API’s
I’m trying to fetch the recording details and timeline file using GRAPH API of Teams, but it is not there is there any way we can fetch them? I can able to fetch the recording using one drive but issue is we need to grant drive scopes which is not good, can’t we achieve using teams graph API’…
Hashing the content of a method in Python
I am looking for a robust way to hash/serialize the content of a method in Python. Use-case: We are doing some file caching the result of a transformation function, and it would be great if it was possible to automatically refresh if transformation function has changed: I am looking for something that could p…
How to draw points of a sphere in a cubic environment?
Given a center point (x0, y0, z0) and a radius (g_radius) I want to use Python to generate points in a sphere in a cubic world (= Minecraft). I’m trying to use this algorithm (I found it here on so) but it’s not precise and I have to increase the number of samples to a ridiculous huge number to ge…
Run multiple terminals from python script and execute commands (Ubuntu)
What I have is a text file containing all items that need to be deleted from an online app. Every item that needs to be deleted has to be sent 1 at a time. To make deletion process faster, I divide the items in text file in multiple text files and run the script in multiple terminals (~130 for deletion
Floating-point errors in cube root of exact cubic input
I found myself needing to compute the “integer cube root”, meaning the cube root of an integer, rounded down to the nearest integer. In Python, we could use the NumPy floating-point cbrt() function: Though this works most of the time, it fails at certain input x, with the result being one less tha…
How to sort MultiIndex using values from a given column
I have a DataFrame with 2-level index and column with the numerical values. I want to sort it by level-0 and level-1 index in such a way that the the order of 0-level index is determined by the sum of values from Value column (descending), and the order of 1-level index is also determined by the values in Val…
Amazon Web Scraping – retrieving price data
I’m currently working on my first project experimenting with web scraping on python. I am attempting to retrieve price data from an amazon url but am having some issues. When I print the price variable, my output is a bit weird: There’s alot of whitespace and the numbers are formatted in weird way…
Select pytorch tensor elements by list of indices
I guess I have a pretty simple problem. Let’s take the following tensor of length 6 Now I would like to to access only the elements at specific indices, lets say at [0, 3, 4]. So I would like to return I found torch.index_select which worked great for a tensor of two dimensions, e.g. dimension (2, 4), b…
Not able to download a file through request in python
When I try to download a file online it doesn’t work for a particular site while it works for others. Why is this happening and what should I do about it? I write the content of the dl request in my case https://drivers.amd.com/drivers/amd-software-adrenalin-edition-22.11.1-win10-win11-nov15.exe (warnin…