Skip to content

Tag: replace

Replace decimals in floating point numbers

Someone on this platform has already helped me with generating the following code: This code ensures that the last decimal is not a 0 or a 9. However, I would like to have no 0’s nor 9’s in all the decimals that are generated (such that it will not be possible to have a number 1.963749 or 3.459007…

Replacing day in date with last day of month

I’ve got a dataframe with column ‘date’, containing yyyy-mm-dd 00:00:00. Python automatically assigned first day of every quarterly month, but I want last day of same month. I’ve tried: and without any success. sample of df: date value 1990-07-01 00:00:00 46.7 1990-10-01 00:00:00 54.2 …

Python .replace() function doesn’t seem to do anything

I’m trying to modify a table I scraped of Yahoo Finance containing dividends over the last 5 years. An example row of this table is: “1.50 Dividend”. As I want to do calculations with this table I needed only the number in the form of a float. So I used the .replace(“Dividend, “&…