- Hands-On Exploratory Data Analysis with Python
- Suresh Kumar Mukhiya Usman Ahmed
- 112字
- 2021-06-24 16:44:56
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.
推薦閱讀
- 大話PLC(輕松動漫版)
- 自己動手寫搜索引擎
- Progressive Web Apps with React
- 零基礎搭建量化投資系統:以Python為工具
- 看透JavaScript:原理、方法與實踐
- C語言程序設計實訓教程
- Access 2016數據庫管
- TradeStation交易應用實踐:量化方法構建贏家策略(原書第2版)
- Expert Data Visualization
- Android Wear Projects
- Visual Studio Code 權威指南
- SQL Server 2008 R2數據庫技術及應用(第3版)
- Java并發編程之美
- Android Development Tools for Eclipse
- Java并發編程:核心方法與框架