Trying to go from a DataFrame where each row is a source entity and columns are the type of relations between one or more entities like this: To one where each row includes a source’s unique target entity and relation type in separate columns: I’ve looked at pandas functionality including stack() …
Create a for loop of wilcoxon rank sum tests in python to generate a list of p-values?
I have a dataframe that follows this format: It is much larger (it has about 1000 genes, i.e., columns). Each number corresponds to an mRNA abundance value. I need to compare AC and SCC subtypes for each gene using the Wilcoxon rank sum test. I need to do this for every gene in my dataset, so I essentially ne…
How to write the program that prints out all positive integers between 1 and given number , alternating between the two ends of the range?
The program should work as follow: My code doesn’t do the same. I think there is should be the 2nd loop, but I don’t really understand how can I do it. Could you possibly give me a hint or advice to solve this task. Thanks. My code looks like this: Answer This should work:
Pandas oversampling ragged sequential data
Trying to use pandas to oversample my ragged data (data with different lengths). Given the following data samples: Data (groups are separated with — for convince): Targets: I would like to balance the minority class. In the sample above, target 1 is the minority class with 2 samples, for ids 1 & 3. …
Cannot install Matplotlib on Python 3.10
I keep getting the following error when I run the above to install Matplotlib. I was initially getting a C++ error and I installed Visual Studio. Answer Matplotlib doesn’t support Python 3.10 at the moment, so you have the following options. See this answer for detailed instructions to downgrade to Pyth…
How many records include each time interval in Pandas?
I have two Pandas event dataframes. The first is for longer events, while the second is for shorter events. The start and end times of the events define them. Every long event is a “container” of at least one short event. Each short event is part of only one long event interval. I try to figure ou…
How to get the coordinate of a checkbox created by tkinter package on a screen
I created a graphical user interface that has 3 checkboxes by using the Checkbox class given in tkinter package. I want to retrieve the screen coordinate of each checkbox. I have been trying to use pyautogui.position() to retrieve the coordianates. However, those values seem wrong because when I used those co…
How to rename values in column having a specific separation symbols?
Values in my DataFrame look like this: I want to remove everything in values of id column after _numeric. So desired result must look like: How to do that? I know that str.replace() can be used, but I don’t understand how to write regular expression part in it. Answer You can use regex(re.search) to fin…
Make Discord.py Bot Only Work In Specific Channels
I was making a bot for my friend using discord.py and I wanted to make it so that it would only work in channel which include the word ticket, made by another bot named Ticket Toll How can I do so? Answer Relevant docs on text channels Unfortunately, Discord’s API does not keep track of who created the …
discord.embed update with role reaction
I’m trying to update a discord.embed with reaction: I create a discord embed with some default information, and add the reaction I want to use, the idea is that when someone react with one of the select reaction, the name of the user is added to the field. ( I actually have 4 commands using the same …