Reindexing pandas timeseries from object dtype to datetime dtype

You could use pd.to_datetime: In [1]: import pandas as pd In [2]: pd.to_datetime(‘2008-02-27’) Out[2]: datetime.datetime(2008, 2, 27, 0, 0) This allows you to “clean” the index (or similarly a column) by applying it to the Series: df.index = pd.to_datetime(df.index) or df[‘date_col’] = df[‘date_col’].apply(pd.to_datetime)

PostgreSQL – how to render date in different time zone?

The key is to switch the local timezone to the desired display timezone, for the duration of the transaction: begin; set local timezone to ‘EST5EDT’; select to_char(‘2012-05-29 15:00:00’::timestamp at time zone ‘CDT’, ‘YYYY-MM-DD HH24:MI:SS TZ’); end; The result is: 2012-05-29 16:00:00 EDT Note that with set [local] timezone it is required to use full time … Read more

Only showing year in django admin, a YearField instead of DateField?

I found this solution which solves the whole thing quite elegantly I think (not my code): import datetime YEAR_CHOICES = [] for r in range(1980, (datetime.datetime.now().year+1)): YEAR_CHOICES.append((r,r)) year = models.IntegerField(_(‘year’), choices=YEAR_CHOICES, default=datetime.datetime.now().year) Edit the range start to extend the list 🙂

How to set current date and time using prepared statement?

Use PreparedStatement#setTimestamp() wherein you pass a java.sql.Timestamp which is constructed with System#currentTimeMillis(). preparedStatement.setTimestamp(index, new Timestamp(System.currentTimeMillis())); // … Alternativaly, if the DB supports it, you could also call a DB specific function to set it with the current timestamp. For example MySQL supports now() for this. E.g. String sql = “INSERT INTO user (email, creationdate) VALUES … Read more

python pandas extract unique dates from time series

If you have a Series like: In [116]: df[“Date”] Out[116]: 0 2012-10-08 07:12:22 1 2012-10-08 09:14:00 2 2012-10-08 09:15:00 3 2012-10-08 09:15:01 4 2012-10-08 09:15:01.500000 5 2012-10-08 09:15:02 6 2012-10-08 09:15:02.500000 7 2012-10-10 07:19:30 8 2012-10-10 09:14:00 9 2012-10-10 09:15:00 10 2012-10-10 09:15:01 11 2012-10-10 09:15:01.500000 12 2012-10-10 09:15:02 Name: Date where each object is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)