Ben Chuanlong Du's Blog

It is never too late to learn.

Date and Time in Python pandas

Date/time utilities in the pandas module are more flexible/powerful than that in the datetime module. It is suggested that you use date/time utilities in the pandas module when you use DataFrame/Series in the pandas module.

  1. pandas.to_datetime works on an iterable object, handles missing values and nano seconds.

  2. pandas.Series.dt.strftime

Hands on pandas.Series in Python

pandas.Series.str

  1. The attribute pandas.Series.str can only be used with Series of str values. You will either encounter an AttributionError (Can only use .str accessor with string values, which use np.object_ dtype in pandas) or find it to yield a Series of NaN's if you invoke it on a Series of non-string values. If you have control of the DataFrame, the preferred way is to cast the type the column to str

Hands on the Python module dask

Installation

  1. You have to install the complete version of Dask (using the command pip3 install dask[complete]) if you need support of extended memory (for handling big data) and schedulers (for performance). The default installation version (pip3 install dask) of Dask does not include those features out-of-box.