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

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.

主站蜘蛛池模板: 宁武县| 乌拉特前旗| 麻栗坡县| 黑河市| 建始县| 浦北县| 凤山县| 新蔡县| 绍兴县| 营口市| 财经| 合江县| 太仆寺旗| 达拉特旗| 乌拉特中旗| 延寿县| 梨树县| 曲阳县| 措勤县| 津市市| 杭锦旗| 长宁县| 罗山县| 达日县| 深圳市| 牙克石市| 靖西县| 阳西县| 安新县| 宁德市| 永仁县| 庆云县| 凉山| 苏州市| 瑞丽市| 沙雅县| 平原县| 昭觉县| 富阳市| 临朐县| 江门市|