Làm việc với dữ liệu thời gian

Ghép nối dữ liệu bằng Pandas dành cho người dùng bảng tính

John Miller

Principal Data Scientist

Nối bằng .merge_ordered()

trộn chuỗi thời gian không kết quả

pd.merge_ordered(cleveland, dallas, on='Game_Date', 
                suffixes=['_CLE', '_DAL'])
Ghép nối dữ liệu bằng Pandas dành cho người dùng bảng tính

Nối bằng .merge_ordered()

trộn chuỗi thời gian

pd.merge_ordered(cleveland, dallas, on='Game_Date', 
                suffixes=['_CLE', '_DAL'])
Ghép nối dữ liệu bằng Pandas dành cho người dùng bảng tính

Nội suy dữ liệu

nội suy khi gộp

pd.merge_ordered(tc2, td2, on='Game_Date', 
                suffixes=['_CLE', '_DAL'], fill_method='ffill')
Ghép nối dữ liệu bằng Pandas dành cho người dùng bảng tính

Nội suy dữ liệu

fgf

pd.merge_ordered(tc2, td2, on='Game_Date', 
                suffixes=['_CLE', '_DAL'], fill_method='ffill')
Ghép nối dữ liệu bằng Pandas dành cho người dùng bảng tính

Gộp theo ngày-giờ gần nhất

  • pandas.merge_asof()
  • khớp theo ngày gần nhất
  • tương tự VLOOKUP(range_lookup=TRUE)
pd.merge_asof(left_df, right_df,
              direction='backward')

Hướng

  • "backward": ngày gần nhất nhưng sớm hơn

  • "forward": ngày gần nhất bằng hoặc muộn hơn

  • "nearest": ngày gần nhất, không xét hướng

Ghép nối dữ liệu bằng Pandas dành cho người dùng bảng tính

Ví dụ về merge_asof

merge_asof

pd.merge_asof(temps, impacts,
              left_on='Game_Date', right_index=True, direction='backward')
Ghép nối dữ liệu bằng Pandas dành cho người dùng bảng tính

Ayo berlatih!

Ghép nối dữ liệu bằng Pandas dành cho người dùng bảng tính

Preparing Video For Download...