Python Pandas join connection parameters detailed data merging data splicing




insert image description here


The join of pandas is based on index to connect dataframe, mainly used for merging based on row index.
As long as the column names of the two tables are different, it can be used directly without any parameters. If the two tables have duplicate column names, you need to specify lsuffix (the column name suffix used by the left data relisted column), rsuffix parameters. The meaning of the parameters is basically the same as that of the merge method.

https://blog.csdn.net/qq_35240689/article/details/125680279?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22125680279%22%2C%22source%22%3A%22qq_35240689%22%7D


insert image description here

df.join(other)

take the intersection

df.join(other, how='inner')

According to overlapping columns ['hour', 'date', 'type']. At this time, you need to set the suffix name after the overlapping columns are merged

df.join(other, on=['hour', 'date', 'type'], how='inner',lsuffix='_df', rsuffix='_other')

insert image description here

Guess you like

Origin blog.csdn.net/qq_35240689/article/details/127058236