I’m new to python. I have a huge text file (about 15gb), so it is not possible to read in all the lines, I have read here how to fix that problem. Now about my problem. Is it possible to read the next line within a for loop without jumping to the beginning of the loop. This is what I
When logging deleted messages, how can I log the deleted image attachments reliably?
So my current event listener will log deleted messages just fine, the problem I’m having right now is that if the message that was deleted has an image attachment to it, most of the time it won’t display properly because the image url cannot be accessed anymore. You will just see the discord loadi…
Color map based on dataframe with countries’ counts values
I have a dataframe called country which contains country_code and frequency counts for countries. country_code frequency 0 US 17600 1 CN 8572 2 KR 1121 3 JP 299 4 DE 199 I wrote a code to plot distribution of countries on a world map: The result I got: Output data Something is wrong with the code, I cannot fi…
Scraping dynamic dropdown with Selenium in Python
I woud like a bit of help with the following. I am trying to scrape the elements of the tickers’ dropdown on this website: https://live.hxro.io/tixwix My code is as follow using selenium This will only return As it is an Ajax call I am not sure how to retrieve the other tickers in an efficient way. I th…
Extract Value From Pandas Dataframe Based On Condition in Another Column
I am trying to develop some code that extracts the power price when a power plant starts up. To give an example refer to the following data frame. Based on this I aiming to develop some code that would store in a dataframe the power price when the plant ops columns transitions from 0 to a number greater than …
How to check 2 string format
I have a string “[ERROR]: test_case_blebleble – FAILURE – 1 hr 47 min” get from console log jenkins In my console log, I have a lot of message like this. so I want to check if have any string like this format FAILURE – 1 hr 47 min then go to get this message. So, in python how we…
Get last friday of each month in python
I want last friday of each month for upcoming three months. This gives me the nearest friday. I want to make sure this is the last friday of this month so that i can add 28 days to get next friday. Answer The easiest way to do this is to use the module dateutil: Don’t assume you can get the
Python dataframe in one column strings delimit by comma, and in another column if pass or fail
How I can count if a country that is in more rows , has failed or passed, enter image description here Like is and the result should be like this enter image description here Because Netherlands is in 4 rows , and has 3 passed and one failed. Answer Use Series.str.split with DataFrame.explode and last call cr…
How do I compare a time value to all the time values in a column in pandas?
I want to apply a condition to a column in a dataframe. The column has time values in the format HH:MM:SS and I want to compare it to a fixed time value(threshold), but I am getting errors. Converting the threshold value to datetime.datetime.strptime gives me error. What I want to ask is – In order to c…
How do I use a feature on a website using python
I am trying to figure out how to activate/click on a feature using python. Like it goes to a page and click on a certain button. How can I do this? Are there any modules that may help? Answer Try using the selenium package in Python. Once you pip install selenium and download chromedriver, you should be able …