date

Expand list of dates by incrementing dates by one day in python

Expand list of dates by incrementing dates by one day in python Question: In Python I have a list of dates as strings: dates = [‘2022-01-01’, ‘2022-01-08’, ‘2022-01-21’] I would like to increment these dates by one day and add them to this list, like so: dates_new = [‘2022-01-01’, ‘2022-01-02’, ‘2022-01-08’, ‘2022-01-09’, ‘2022-01-21’, ‘2022-01-22’] What …

Total answers: 3

Is there a way to select all rows created today(current date), if that column has time format date and time?

Is there a way to select all rows created today(current date), if that column has time format date and time? Question: If I have a table that contains: table_id id_from_other_table date_time_when_this_row_was_added [(1, 200, ‘2023-01-06 08-11-21’)] [(2, 200, ‘2023-01-07 07-21-21’)] [(3, 200, ‘2023-01-07 08-10-10′)] Can I get all the rows that were created at today’s date …

Total answers: 1

Python: "object' does not match format '%Y-%W-%w'"

Python: "object' does not match format '%Y-%W-%w'" Question: I am working with Python in Spotfire and am trying to convert fiscal weeks to the date of the Monday of the input fiscal week. I have attempted to implement the solution provided here to no avail. My script is as follows: import datetime d= datetime.datetime.strptime(str(fw), "%Y-%W-%w") …

Total answers: 1

Time series resample seems to result in wrong data

Time series resample seems to result in wrong data Question: I have data with 30 minutes interval. When I resample it to 1 hour I get kind of low values. Original data: 2022-12-31 22:00:00+01:00;7.500000 2022-12-31 22:30:00+01:00;8.200000 2022-12-31 23:00:00+01:00;10.800000 2022-12-31 23:30:00+01:00;9.500000 2023-01-01 00:00:00+01:00;12.300000 2023-01-01 00:30:00+01:00;168.399994 2023-01-01 01:00:00+01:00;157.399994 2023-01-01 01:30:00+01:00;73.199997 2023-01-01 02:00:00+01:00;59.700001 2023-01-01 02:30:00+01:00;74.000000 After df = …

Total answers: 1

Create a new DataFrame using pandas date_range

Create a new DataFrame using pandas date_range Question: I have the following DataFrame: date_start date_end 0 2023-01-01 16:00:00 2023-01-01 17:00:00 1 2023-01-02 16:00:00 2023-01-02 17:00:00 2 2023-01-03 16:00:00 2023-01-03 17:00:00 3 2023-01-04 17:00:00 2023-01-04 19:00:00 4 NaN NaN and I want to create a new DataFrame which will contain values starting from the date_start and …

Total answers: 2

How to shift a column by 1 year in Python

How to shift a column by 1 year in Python Question: With the python shift function, you are able to offset values by the number of rows. I’m looking to offset values by a specified time, which is 1 year in this case. Here is my sample data frame. The value_py column is what I’m …

Total answers: 1

Marking valid days on time series

Marking valid days on time series Question: The following is my code: x = ts.loc[::-1, "validday"].eq(0) x = x.groupby(x.index.to_period(‘M’), sort=False).cumsum().head(35) x.head(35) Current Output: Date 2022-11-14 1 2022-11-13 1 2022-11-12 1 2022-11-11 2 2022-11-10 3 2022-11-09 4 2022-11-08 5 2022-11-07 6 2022-11-06 6 2022-11-05 7 2022-11-04 7 2022-11-03 8 . . . . . . . …

Total answers: 1

Turning the dataframe upside down and performing groupby

Turning the dataframe upside down and performing groupby Question: x = ts.loc[::-1, "column_1"].eq(0) #First Line of code for reference x.groupby(pd.Grouper(freq="M")).cumsum().head(35) #Second Line of code for reference Goal: I have a timeseries dataframe which i need to turn it upside down and perform the groupby problem: the first line of code above is succesfully turning my …

Total answers: 1

Format dates on an entire column with ExcelWriter and Openpyxl

Format dates on an entire column with ExcelWriter and Openpyxl Question: I’m trying to write a pandas DataFrame to Excel, with dates formatted as "YYYY-MM-DD", omitting the time. Since I need to write multiple sheets, and I want to use some advanced formatting opens (namely setting the column width), I’m using an ExcelWriter object and …

Total answers: 2