I just wrote a script in jupyer notebook and I’m wondering what’s the best format I should save this file as if I want to share it with other people so they can run it on their windows computer? I tried to convert my .ipynb to both .py and .exe, but none seem to work… maybe I’m doing s…
Find ‘next’ non-null value in column
I am trying to create a new column which appends the row index of next non-null value next to the current non-null value using the following df as a starting point: The output would look like this: I have found a link that touches on the issue but I could not adapt to suit.. How can I get the index
call variable in method within the same class
In this example code: is there a way to call the average and total variables in the math method without putting it in the return function (I want the math function to only return the length of the list)? I tried this: but this gives an error. I want to be able to call the variables in one line. Any
How to create new table with first name only in table
I have some data that looks like this: I’d like to create a new table with the name column but with the first name only. Answer This gets the first substring before the space character in name as first_name. first_name Arizona Emerald
Is there a O(n) way to find the most repeated item in list without using counter
I need a solution that is O(n) for finding most repeated element in a list. If 2 or more numbers are repeated the same amount of time return smallest number. Output should be 4 which should give the count of 3 Answer You could use max and groupby: Or use a dict as a counter: Or if your data has
I want to filter rows from data frame where the year is 2020 and 2021 using re.search and re.match functions
Data Frame: I want the data frame which consists for only year with 2020 and 2021 using search and match methods. Answer
Input variable name as raw string into request in python
I am kind of very new to python. I tried to loop through an URL request via python and I want to change one variable each time it loops. My code looks something like this: I want to have the url change at every loop to like url_part1+code+url_part3 and then url_part1+NEXTcode+url_part3. Sadly my request badly…
How to display questions based on subcategory using Django Rest Framework?
I want to display all questions based on subcategory. This is my code : models.py serializers.py view.py /api/subcategory : /api/questions : From the data above I have 2 subcategories Mathematics and History and have 3 questions based on the subcategory, 2 questions about mathematics and 1 question about hist…
discord.py :: How do I make on_message_delete ignore a certain user / role via an embed?
I have a log channel set so if a user deletes a message, it gets sent to the channel so my moderators and myself can see deleted messages. I want to make it so this does not send an embed showcasing what my moderators or myself deleted to avoid clutter. Is there a way to do this? Answer You can
Python: Round decimal places after seconds in timestamp
I have this series: Initially, I wanted to round to seconds by doing: However, I am trying to merge this dataset to another of higher frequency. So I’d like to round the decimal places of the timestamp instead. Example: 2021-06-15 16:23:04.388 would become 2021-06-15 16:23:04.380 How can I do this? to a…