below are my two dfs I want to replace the column ‘a’ of df with values in column ‘a’ of dd. Any empty rows are replaced by zero “only” for column ‘a’. All other columns of df remain unchanged. so column ‘a’ should contain 3,3,0,0,0 Answer This is pr…
Tag: python
How can I save multiple dataframes onto one excel file (as separate sheets) without this error occurring?
I have the following Python code: I’m reading the excel file which contains two sheets and then saving those sheets into a new excel file but unfortunately I’m receiving the following error: Any ideas on how I can fix this?. Thanks. Answer Change [0] to 0 in pd.read_excel(path, sheet_name = [0]) w…
Draw circle with PIL (Old ones doesn’t works)
I am trying to draw a circle with PIL, but I get an attribute error. Current code is for square. Part of code to draw: My whole code: Code Answer You can use either ImageDraw.arc() or ImageDraw.ellipse. Or:
How to scroll down in side menu
I am new to selenium python, how to scroll down to the bottom of the filter in swiggy. When I tried the background page is getting scroll instead of filter. enter image description here Answer First you have to be sure to target the correct element, in this case the side menu, then with javascript you can edi…
How to find and calculate common letters between words in pandas
I have a dataset with some words in it and I want to compare 2 columns and count common letters between them. For e.g I have: And I want to have smth like that: Answer You can use a list comprehension with help of itertools.takewhile: output: NB. the logic was no fully clear, so here this stops as soon as
Selenium cannot click button because there is a div overlay
I am trying to scrap this webpage https://www.tecnocasa.es/venta/piso/barcelona/barcelona/510567.html, the code i use is the following, and i think is correct: The buttons are found but when i try to click one i have the error <button class=”btn-default”> is not clickable at point (1138,829)…
Python List to Dictionary from a file
I have a file of notes that im trying to convert to a dictionary. I got the script working but failed to output the data im looking for when there are repeated values. In short took the file commands or comments which are separated by # as per below. I take that list and seperate the 1st column “keyR…
How to group by time-interval from bottom to top using Pandas resample functionality?
I am working with historic data of some stocks. I want to group data by certain time intervals (like 1hr, 3days, etc). Pandas gives amazing functionality of doing this with very less efforts using resampling. But it happens from top-to-bottom (below image). Like – Here, I want to group from bottom-to-to…
Display/return last 12 and 24 months with year from current month and year using python (Creating Date range)
Question: Here i got first date of the month but along with first date i want last date of the month as well. So how it will be possible. What change should i make to get the last date of the month as well? Answer To ge the end of the months you can do: If you want a single
Instaloader – receive media count for inputted hashtag
I’m looking to simply input a series of hashtags and be outputted with those hashtags and their associated post count. I believe I can use the mediacount property: “The count of all media associated with this hashtag.” As found here: https://instaloader.github.io/module/structures.html?highl…