- 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.
推薦閱讀
- Visual C++程序設(shè)計(jì)教程
- Python數(shù)據(jù)分析基礎(chǔ)
- MySQL數(shù)據(jù)庫(kù)管理與開(kāi)發(fā)(慕課版)
- Python機(jī)器學(xué)習(xí)基礎(chǔ)教程
- 精通Python自動(dòng)化編程
- Web前端應(yīng)用開(kāi)發(fā)技術(shù)
- FFmpeg開(kāi)發(fā)實(shí)戰(zhàn):從零基礎(chǔ)到短視頻上線(xiàn)
- 創(chuàng)意UI:Photoshop玩轉(zhuǎn)APP設(shè)計(jì)
- Web Developer's Reference Guide
- Java高并發(fā)編程詳解:深入理解并發(fā)核心庫(kù)
- 超好玩的Scratch 3.5少兒編程
- 游戲設(shè)計(jì)的底層邏輯
- Getting Started with JUCE
- Apache Solr for Indexing Data
- C#大學(xué)實(shí)用教程