“轴"的含义是什么? Pandas DataFrame中的属性? [英] What is the meaning of "axis" attribute in a Pandas DataFrame?

查看:118
本文介绍了“轴"的含义是什么? Pandas DataFrame中的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下面的示例为例:

>>> df1 = pd.DataFrame({"x":[1, 2, 3, 4, 5], 
                        "y":[3, 4, 5, 6, 7]}, 
                      index=['a', 'b', 'c', 'd', 'e'])

>>> df2 = pd.DataFrame({"y":[1, 3, 5, 7, 9], 
                        "z":[9, 8, 7, 6, 5]}, 
                      index=['b', 'c', 'd', 'e', 'f'])

>>> pd.concat([df1, df2], join='inner')

输出为:

   y
a  3
b  4
c  5
d  6
e  7
b  1
c  3
d  5
e  7
f  9

由于axis=0是列,所以我认为concat()仅考虑在两个数据框中都找到的.但实际输出会考虑在两个数据框中都找到的.

Since axis=0 is the columns, I think tha concat() only considers columns that are found in both dataframes. But the acutal output considers rows that are found in both dataframes.

axis参数的确切含义是什么?

What is the exactly meaning of axis parameter?

推荐答案

如果有人需要视觉描述,则图像如下:

If someone needs visual description, here is the image:

这篇关于“轴"的含义是什么? Pandas DataFrame中的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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