我需要加入包含无/无的字段。但是熊猫出卖那是正常的吗? (模拟相交,需要保留第一个dframe的索引)
a = pandas.DataFrame([[None, 1], [1, 2]], index=[10, 11], columns=['a', 'b'])
b = pandas.DataFrame([[None, 2], [1, 2]], columns=['c', 'd'])
a.merge(
right=b.drop_duplicates().set_index(b.columns.to_list()),
how='inner',
left_on=a.columns.to_list(),
right_index=True)
# a b
# 11 1.0 2
# 11 1.0 2 # Where does this row come from ???
#
# While i was expecting just:
# a b
# 11 1.0 2
但是
a = pandas.DataFrame([[None, 1], [1, 2]], index=[10, 11], columns=['a', 'b'])
b = pandas.DataFrame([[None, 1], [1, 2]], columns=['c', 'd'])
a.merge(
right=b.drop_duplicates().set_index(b.columns.to_list()),
how='inner',
left_on=a.columns.to_list(),
right_index=True)
# a b
# 11 1.0 2
# Where is the row [None, 1] ???
#
# While i was expecting:
# a b
# 10 NaN 1
# 11 1.0 2
如何与无人一起加入?