Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added keys example
  • Loading branch information
palewire committed Jan 2, 2017
commit afa750252ea9d46f8e318d8d58dff6547af7b575
27 changes: 27 additions & 0 deletions pandas/tools/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,33 @@ def concat(objs, axis=0, join='outer', join_axes=None, ignore_index=False,
3 d
dtype: object

Add a ``hierarchical index`` at the outermost level of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to add backtick quotes around 'hierarchical index'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've fixed this.

the data.

>>> s1 = pd.Series(['a', 'b', 'c'])
>>> s2 = pd.Series(['c', 'd', 'e'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here as well (you can use the same s1 and s2 I think)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change coming.

>>> c = pd.concat([s1, s2], keys=["s1", 's2',])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use consistent quotes within the keys list (eg always single quotes)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've fixed this.

>>> c
s1 0 a
1 b
2 c
s2 0 c
1 d
2 e
dtype: object
>>> c.ix['s1']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above example is good. But I would leave out the examples on indexing the result to keep the examples focused on concat (such examples would certainly be nice for the tutorial docs)

Maybe add an example with axis=1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the ix calls and added axis=1 to my list for later.

0 a
1 b
2 c
dtype: object
>>> c.ix['s2']
0 c
1 d
2 e
dtype: object
>>> c.ix['s1'].ix[0]
'a'

Combine two ``DataFrame`` objects with identical columns.

>>> df1 = pd.DataFrame(
Expand Down