Skip to content

DOC: additional join examples in "10 Minutes to pandas" #13029

Closed
@DavidDobr

Description

@DavidDobr

Tutorial at pandas.pydata.org/pandas-docs/stable/10min.html has the following code, where the obvious mistake is having only 1 key "foo" instead of 2 keys: "foo" and "bar" throughout the whole example


Join

SQL style merges. See the Database style joining

In [77]: left = pd.DataFrame({'key': ['foo', 'foo'], 'lval': [1, 2]})

In [78]: right = pd.DataFrame({'key': ['foo', 'foo'], 'rval': [4, 5]})

In [79]: left
Out[79]: 
   key  lval
0  foo     1
1  foo     2

In [80]: right
Out[80]: 
   key  rval
0  foo     4
1  foo     5

In [81]: pd.merge(left, right, on='key')
Out[81]: 
   key  lval  rval
0  foo     1     4
1  foo     1     5
2  foo     2     4
3  foo     2     5

Here is how it should be (replaced second 'foo' with 'bar':

screenshot from 2016-04-29 14-49-45

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions