数据预处理(时序数据)
Dataframe某一列去除重复项
df = df['name'].drop_duplicates() 1
创建一个空的Dateframe
df = pd.DataFrame(columns=[]) 1
Dataframe根据列值选择特定行
new_df= df.loc[df['name']=='some_value'] 1
Dateframe根据索引排序
df = df.sort_index() 1
Dataframe输出显示的行or列
pd.set_option('display.max_rows', 8/None) pd.set_option('display.max_columns', 8/None) 12
判断Dataframe是否为空
if df is None: 1
取Dataframe某列和某几列
df = df['column_name'] df = df[['column_1','column_2']] 12
Dataframe添加某列向上/向下1移位列并插入第1列后
df.new_column = df.column.shift(-1/1) df.insert(1,'new_column',df.new_column) 12
复制dataframe
new_df= df.copy()