慕村9548890
假设您要回填值,然后删除任何列中显示的任何重复项,此示例有效:import pandas as pdimport numpy as npdata = [ ['POINT_1.1', 'POINT_1.2', pd.NA], [pd.NA, pd.NA, 'POINT_1.3'], ['POINT_2.1', 'POINT_2.2', pd.NA], [pd.NA, pd.NA, 'POINT_2.3']]df = pd.DataFrame(data)df# 0 1 2# 0 POINT_1.1 POINT_1.2 <NA># 1 <NA> <NA> POINT_1.3# 2 POINT_2.1 POINT_2.2 <NA># 3 <NA> <NA> POINT_2.3t = df.T.bfill().T.bfill()t# 0 1 2# 0 POINT_1.1 POINT_1.2 POINT_1.3# 2 POINT_2.1 POINT_2.2 POINT_2.3for column in t.columns: t = t.drop_duplicates(column)t# 0 1 2# 0 POINT_1.1 POINT_1.2 POINT_1.3# 2 POINT_2.1 POINT_2.2 POINT_2.3