Reputation: 2426
I've reviewed the official docs and several samples of example code. Example code has used an alternative syntax and this question is to ask whether the two syntaxes have different effects, or whether they are just two ways to do the same thing.
The official concat syntax is like:
s1 = pd.Series(['a', 'b'])
s2 = pd.Series(['c', 'd'])
pd.concat([s1, s2])
The alternative syntax I have seen working is like:
df = pd.concat((
df,
pd.get_dummies(df['industry'])), axis=1)
In short: I see the swapping of brackets for parentheses and my question is whether this difference is innocuous or not. I can't see any difference in my own usage.
Upvotes: 0
Views: 72
Reputation: 153460
Per the documentation:
(https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.concat.html#pandas-concat)
objs: a sequence or mapping of Series or DataFrame objects If a mapping is passed, the sorted keys will be used as the keys argument, unless it is passed, in which case the values will be selected (see below). Any None objects will be dropped silently unless they are all None in which case a ValueError will be raised.
In python (https://docs.python.org/3/library/stdtypes.html#sequence-types-list-tuple-range)
Sequence Types — list, tuple, range¶ There are three basic sequence types: lists, tuples, and range objects. Additional sequence types tailored for processing of binary data and text strings are described in dedicated sections.
So, both brackets for list can be used or paranthesis for tuples.
Upvotes: 1