In the doc of Series, the use parameter of name
and fastpath
is not explained. What do they do?
The name of a Series becomes its index or column name if it is used to form a DataFrame. It is also used whenever displaying the Series using the interpreter. Returns label (hashable object) The name of the Series, also the column name if part of a DataFrame. See also Series.rename.
A pandas Series has no column labels, as it is just a single column of a DataFrame . A Series does have row labels.
You can use the rename() method of pandas. DataFrame to change column/index name individually. Specify the original name and the new name in dict like {original name: new name} to columns / index parameter of rename() . columns is for the column name, and index is for the index name.
The name
argument allows you to give a name to a Series
object, i.e. to the column. So that when you'll put that in a DataFrame
, the column will be named according to the name
parameter.
example:
In [1]: s = pd.Series(["A","B","C"], name="foo") In [2]: s Out[2]: 0 A 1 B 2 C Name: foo, dtype: object In [3]: pd.DataFrame(s) Out[4]: foo 0 A 1 B 2 C
If you don't give a name
to your Series
it will be named automatically. Here it will be a 0
in the dataframe
object:
0 0 A 1 B 2 C
For the fastpath
, it's an internal parameter and an issue has already been reported :
https://github.com/pydata/pandas/issues/6903
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With