- 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.
推薦閱讀
- Go Web編程
- 程序員面試白皮書
- JavaScript全程指南
- ASP.NET Core 5.0開發(fā)入門與實戰(zhàn)
- 劍指Offer(專項突破版):數(shù)據(jù)結(jié)構(gòu)與算法名企面試題精講
- C語言程序設(shè)計
- Servlet/JSP深入詳解
- C#程序設(shè)計教程
- 零基礎(chǔ)學(xué)Java(第4版)
- Rust Essentials(Second Edition)
- 零基礎(chǔ)學(xué)HTML+CSS
- Android Studio開發(fā)實戰(zhàn):從零基礎(chǔ)到App上線 (移動開發(fā)叢書)
- 量子計算機(jī)編程:從入門到實踐
- HikariCP數(shù)據(jù)庫連接池實戰(zhàn)
- Kohana 3.0 Beginner's Guide