在Series中通过dt就可以获得其日期属性
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df = pd.read_csv('ahdy-2019-03-04-data.csv', sep=',', parse_dates=['发布时间'])
print(df.shape)
print(df.columns)
print(df.dtypes)
df = df.loc[df['发布时间'].dt.year == 2019]
print(df['发布时间'])
这是其他几个可能用到的,比如变成字符串就是.str,比如我们想通过字符串的长度筛选数据就可以通过str.len() == xx
pd = pd[pd['sid'].str.len() == 18]
str = CachedAccessor("str", StringMethods)
dt = CachedAccessor("dt", CombinedDatetimelikeProperties)
cat = CachedAccessor("cat", CategoricalAccessor)
plot = CachedAccessor("plot", gfx.SeriesPlotMethods)
sparse = CachedAccessor("sparse", SparseAccessor)