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

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.

主站蜘蛛池模板: 卢氏县| 安陆市| 茂名市| 东乡族自治县| 高要市| 汽车| 金塔县| 搜索| 甘洛县| 辉县市| 如皋市| 尼勒克县| 朝阳区| 沛县| 乐至县| 安达市| 汉源县| 南投市| 南靖县| 江阴市| 庆云县| 定西市| 星座| 咸丰县| 盐源县| 阳春市| 华亭县| 宁武县| 鄂托克前旗| 内乡县| 二连浩特市| 义乌市| 武义县| 永济市| 大城县| 东安县| 保靖县| 老河口市| 恩平市| 扎兰屯市| 福安市|