官术网_书友最值得收藏!

Converting the date

Next, we will convert the date.

Check the datatypes of each column as shown here:

dfs.dtypes

The output of the preceding code is as follows:

subject object
from object
date object
to object
label object
thread float64
dtype: object

Note that a date field is an object. So, we need to convert it into a DateTime argument. In the next step, we are going to convert the date field into an actual DateTime argument. We can do this by using the pandas to_datetime() method. See the following code:

dfs['date'] = dfs['date'].apply(lambda x: pd.to_datetime(x, errors='coerce', utc=True))

Let's move onto the next step, that is, removing NaN values from the fields.

主站蜘蛛池模板: 吉木萨尔县| 华池县| 苍山县| 云梦县| 高阳县| 茂名市| 额尔古纳市| 德格县| 梅州市| 武川县| 册亨县| 锡林郭勒盟| 广州市| 方正县| 新乡县| 凉城县| 克拉玛依市| 灵璧县| 旬阳县| 河西区| 崇义县| 丹棱县| 鲁甸县| 宁城县| 海兴县| 稷山县| 交口县| 康乐县| 荆州市| 晋江市| 临江市| 武汉市| 杭州市| 彰武县| 昌黎县| 固安县| 儋州市| 南召县| 东丽区| 仪陇县| 宜昌市|