pandas 系列的名称参数是什么? [英] What is the name parameter in Pandas Series?

查看:88
本文介绍了 pandas 系列的名称参数是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

系列的文档中,不解释namefastpath的参数.他们是做什么的?

In the doc of Series, the use parameter of name and fastpath is not explained. What do they do?

推荐答案

name参数允许您为Series对象(即列)命名.这样,当您将其放入DataFrame时,该列将根据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.

示例:

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

如果不给Series提供name,它将自动命名.这是dataframe对象中的0:

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

对于fastpath,它是一个内部参数,并且已经报告了一个问题:

For the fastpath, it's an internal parameter and an issue has already been reported :

https://github.com/pydata/pandas/issues/6903

这篇关于 pandas 系列的名称参数是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆