3、日期解析

In this notebook, we’re going to work with dates.

Let’s get started!

数据集「catalog.csv2F202401242Fstorage%2Fgoog4_request&X-Goog-Date=20240124T025847Z&X-Goog-Expires=259200&X-G.csv」,下载链接:链接:https://pan.quark.cn/s/d14c626a5439

文章目录

  • 1、设置我们的环境
  • 2、检查我们日期列的数据类型
  • 3、将我们的日期列转换为日期时间
  • 4、选择月份的某一天
  • 5、绘制月份的某一天以检查日期解析

1、设置我们的环境

我们需要做的第一件事是加载我们将要使用的库和数据集。我们将使用一个包含2007年至2016年间发生的滑坡信息的数据集。在接下来的练习中,你将把你的新技能应用到一个全球地震的数据集中。

In [1]:

# 我们将使用的模块
import pandas as pd
import numpy as np
import seaborn as sns
import datetime

# 读取我们的数据
landslides = pd.read_csv("../input/landslide-events/catalog.csv")

# 设置种子以保证可重复性
np.random.seed(0)

现在我们准备好查看一些日期了!

2、检查我们日期列的数据类型

我们首先看一下数据的前五行。

In [2]:

landslides.head()

Out[2]:

id date time continent_code country_name country_code state/province population city/town distance geolocation hazard_type landslide_type landslide_size trigger storm_name injuries fatalities source_name source_link
0 34 3/2/07 Night NaN United States US Virginia 16000 Cherry Hill 3.40765 (38.600900000000003, -77.268199999999993) Landslide Landslide Small Rain NaN NaN NaN NBC 4 news http://www.nbc4.com/news/11186871/detail.html
1 42 3/22/07 NaN NaN U

你可能感兴趣的:(数据清洗,Data,Cleaning,python,数据分析,数据清洗)