eland.DataFrame.drop#
- DataFrame.drop(labels=None, axis=0, index=None, columns=None, level=None, inplace=False, errors='raise')#
返回删除了请求轴中的标签的新对象。
参数#
- labels
要删除的索引或列标签。
- axis
是否从索引 (0 / 'index') 或列 (1 / 'columns') 中删除标签。
- index, columns
指定轴的替代方法 (labels, axis=1 等同于 columns=labels)。
- level
对于 MultiIndex - 不支持
- inplace
如果为 True,则就地执行操作并返回 None。
- errors
如果为 'ignore',则抑制错误并删除现有标签。
返回值#
- dropped
调用者的类型
另请参见#
示例#
删除一列
>>> df = ed.DataFrame('https://127.0.0.1:9200', 'ecommerce', columns=['customer_first_name', 'email', 'user']) >>> df.drop(columns=['user']) customer_first_name email 0 Eddie eddie@underwood-family.zzz 1 Mary mary@bailey-family.zzz 2 Gwen gwen@butler-family.zzz 3 Diane diane@chandler-family.zzz 4 Eddie eddie@weber-family.zzz ... ... ... 4670 Mary mary@lambert-family.zzz 4671 Jim jim@gilbert-family.zzz 4672 Yahya yahya@rivera-family.zzz 4673 Mary mary@hampton-family.zzz 4674 Jackson jackson@hopkins-family.zzz [4675 rows x 2 columns]
通过索引值删除行 (axis=0)
>>> df.drop(['1', '2']) customer_first_name email user 0 Eddie eddie@underwood-family.zzz eddie 3 Diane diane@chandler-family.zzz diane 4 Eddie eddie@weber-family.zzz eddie 5 Diane diane@goodwin-family.zzz diane 6 Oliver oliver@rios-family.zzz oliver ... ... ... ... 4670 Mary mary@lambert-family.zzz mary 4671 Jim jim@gilbert-family.zzz jim 4672 Yahya yahya@rivera-family.zzz yahya 4673 Mary mary@hampton-family.zzz mary 4674 Jackson jackson@hopkins-family.zzz jackson [4673 rows x 3 columns]