0
Follow
0
View

Merge on Nan - The bug is the behavior I want. Should I worry about future correction?

wangshanglantian 注册会员
2023-01-25 20:55

As you correctly pointed out, in future, there is a possibility of not being able to join on NaN. Depending on the programming language, this behavior changes.

The easiest future-proof solution would be to replace NaN with "NA" or a similar string. You may replace it back to to NaN post merging if required.

df = pd.DataFrame({'col1':[np.nan, 'match'], 'col2':[1,2]}).fillna("NA")
df2 = pd.DataFrame({'col1':[np.nan, 'no match'], 'col3':[3,4]}).fillna("NA")
pd.merge(df,df2, on='col1')

About the Author

Question Info

Publish Time
2023-01-25 20:55
Update Time
2023-01-25 20:55

Related Question

Swift的Dispatchqueue和Flutter的Future有什么不同?

<:>在索引40:com. recognition .app- mergedebugresources -33:/values/values.xml)

如何找到哪个Future导致“Future异常从未被检索”

在另一个管道中的MergeMany操作符中使用value

Future返回空列表

如何为ListenableFuture回调写junit测试

CrossTalk Correction 和Green Balance是同一个过程吗?

MergeMap vs ConcatMap:我们能两者兼得吗?

这一句不太理解l1.next = mergeTwoLists(l1.next, l2);

带有空值的JSON_MERGE_PATCH(Javascript)