I want to match certain parts of 2 dataframes by date and time and merge them into one of them. But my code is not working. I have 2 dataframe df and df2. First is df and second is df2. What can I do for this? I want to add Weather, Temp, Feels and after that to df. here is
Tag: datetime
Adding date to pd.to_datetime
I’m looking for a way to add custom date to pd.to_datetime. So, for example: Print: pd.to_datetime keeps adding today’s date which is fine in case of csv_file but csv_file2 need to contain tomorrow’s date. Here’s sample of csv files: Answer Idea is create helper column file for distingush if tomorrow and last add 1 day by condition for compare new
How to read 24:00 hour?
I have a csv file with 24:00 hour instead of 00:00 and try to read it with pandas. I found solution and try to adopt it. The problem is, I get an error and don’t know how to fix it. Can someone help me? My csv: The code I got from the link above adopted to my case: The error
Convert object column format “%d-%b-%y” to datetime, where month initial letter is Upper or lowercase and Month can be in italian or english
For this dataframe (link): I want to convert columns [Issue date, Redemption date] to datetime format. The format variations are: Month is lower case: 01-set-09 Month in Italian 01-set-09 (settembre-italian instead of September-English) I have tried using: and this one: however i get the following error: Here is a working code that generates my error: EDIT FROM MrFuppes answer when
Does Pandas account for leap years when calculating dates
I am trying to add 148.328971 years precisely from the day 01.01.2000 using pandas. I first converted this to days by multiplying it by 365. So here is my question, albeit probably a dumb one. Does pandas consider leap years when calculating days? The obvious answer is yes because it is calculating days but I have to make sure, precision
Python: Determining period of the day based on hour using a for loop and conditionals
I would like to name the period of the day based on hourly information to my dataframe. For this, I am attempting the following: However, when double-checking if the length of my day_period list is the same as that of my dataframe (df)… they differ and they shouldn’t. I can’t spot the mistake. How can I fix the code? Here’s
How to create a specific date_range for each unique id in a dataframe?
I want to create a date range for each customer in a dataset. Each customer has its own range. How can this be done without a for loop? Sample data: Now I want to have one month for each row for each customer, for their min and max dates respectively, to get: My attempt is to use a for loop,
Python Dataframe Convert hh:mm:ss object into datetime format
I am trying to convert HH:MM into the datetime format. It converts but it adds an unwanted year 1900. I don’t know why? My code: Present output Why I need this? I am plotting HH:MM on the x-axis and value on the y-axis. The x-axis ticks look crazy and we cannot read even after I used plt.gcf().autofmt_xdate(). Answer autofmt_xdate() will
Get all dates between start and end date pandas columns
I’m trying to get a list of dates between two start and end date pandas columns, with individual IDs. I’ve found an answer that is basically what I’m after (https://stackoverflow.com/a/53409207/14463396) but this only works if the periods between the start and end dates don’t overlap, and I can’t seem to work out how to adapt this/use an alternative method to
How do I check if a date in a date column is between two dates in different columns using pandas?
I’m trying to figure out how to check if a date in one column is between the dates from two separate columns. I checked Check if a date column is in a range of dates – pandas but it wasn’t quite the same problem. I use the unique identifier of each row to know if that row’s date needs to