gpt4 book ai didi

python - Pandas :将一个数据框的特定列连接到另一个数据框

转载 作者:太空宇宙 更新时间:2023-11-04 07:53:24 24 4
gpt4 key购买 nike

<分区>

我在 pandas 中有 2 个以下数据框:

电影

+---+------------------------------+--------------+-----------+
| | movie title | genre | tconst |
+---+------------------------------+--------------+-----------+
| 0 | Edison Kinetoscopic Record | Documentary | tt0000008 |
+---+------------------------------+--------------+-----------+
| 1 | La sortie des usines Lumière | Documentary | tt0000010 |
+---+------------------------------+--------------+-----------+
| 2 | The Arrival of a Train | Documentary | tt0000012 |
+---+------------------------------+--------------+-----------+
| 3 | The Oxford and Cambridge | NaN | tt0000025 |
+---+------------------------------+--------------+-----------+
| 4 | Le manoir du diable | Short|Horror | tt0000091 |
+---+------------------------------+--------------+-----------+

船员

+---+-----------+-----------+---------+------+
| | tconst | directors | writers | year |
+---+-----------+-----------+---------+------+
| 0 | tt0000001 | nm0005690 | \N | 2001 |
+---+-----------+-----------+---------+------+
| 1 | tt0000002 | nm0721526 | \N | 2002 |
+---+-----------+-----------+---------+------+
| 2 | tt0000003 | nm0721526 | \N | 2003 |
+---+-----------+-----------+---------+------+
| 3 | tt0000004 | nm0721526 | \N | 2004 |
+---+-----------+-----------+---------+------+
| 4 | tt0000005 | nm0005690 | \N | 2005 |
+---+-----------+-----------+---------+------+

如何创建一个新的数据框,将 directorsyear 列仅连接到 movies 数据框(使用 tconst 列)?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com