python pandas merge multiple csv files

I have around 600 csv file datasets, all have the very same column names [‘DateTime’, ‘Actual’, ‘Consensus’, ‘Previous’, ‘Revised’], all economic indicators and all-time series data sets. the aim is …

How do I force Django queryset return datetime field in current timezone?

I have Django model: class Deal(models.Model): … created_at = models.DateTimeField(auto_now_add=True) When I get created_at value by queryset, it always return to me the datetime value …

Seconds until end of day in python

There’s another question here that asks how many seconds since midnight – this question is the opposite. How do I get the seconds until the end of the day, from the current time, using python? Answer The cleanest way I found to accomplish this is Taken from http://wontonst.blogspot.com/2017/08/time-until-end-of-day-in-python.html This however, is not the fastest solution – you can run your own calculations to get a speedup timeit results: Slow: 3.55844402313 Fast: 1.74721097946 (103% speedup) As pointed out by Jim Lewis, there is a case where this faster function breaks on the day daylight savings starts/stops.

Pandas: Group by calendar-week, then plot grouped barplots for the real datetime

EDIT I found a quite nice solution and posted it below as an answer. The result will look like this: Some example data you can generate for this problem: codes = list(‘ABCDEFGH’); dates = pd….

Calculate Pandas DataFrame Time Difference Between Two Columns in Hours and Minutes

I have two columns, fromdate and todate, in a dataframe. import pandas as pd data = {‘todate’: [pd.Timestamp(‘2014-01-24 13:03:12.050000’), pd.Timestamp(‘2014-01-27 11:57:18.240000’), pd.Timestamp(‘…

Convert pandas timezone-aware DateTimeIndex to naive timestamp, but in certain timezone

You can use the function tz_localize to make a Timestamp or DateTimeIndex timezone aware, but how can you do the opposite: how can you convert a timezone aware Timestamp to a naive one, while …

A faster strptime?

I have code which reads vast numbers of dates in ‘YYYY-MM-DD’ format. Parsing all these dates, so that it can add one, two, or three days then write back in the same format is slowing things down …

Make Sqlalchemy Use Date In Filter Using Postgresql

I’m trying to perform the following query in Sqlalchemy. Select * from “Mytable” where Date(date_time_field) = “2011-08-16”; I have tried several methods. Some here on SO. But none seems “realistic” …

Python: how to compute date ranges from a list of dates?

I have a list of dates, for example: [‘2011-02-27’, ‘2011-02-28’, ‘2011-03-01’, ‘2011-04-12’, ‘2011-04-13’, ‘2011-06-08’] How do I find the contiguous date ranges contained within those dates? In …

Checking date against date range in Python

I have a date variable: 2011-01-15 and I would like to get a boolean back if said date is within 3 days from TODAY. Im not quite sure how to construct this in Python. Im only dealing with date, not datetime. My working example is a “grace period”. A user logs into my site and if the grace period is within 3 days of today, additional scripts, etc. are omitted for that user. I know you can do some fancy/complex things in Python’s date module(s) but Im not sure where to look. Answer In Python to check a range you