pandas删除最后一列,熊猫-删除DataFrame的最后一列

I have a DataFrame and I would like to drop the last column of it. Until now I had just been dropping what I believed to be the final column withif len(fish_frame.columns) == 4:del fish_frame[3].Right...
摘要由CSDN通过智能技术生成

I have a DataFrame and I would like to drop the last column of it. Until now I had just been dropping what I believed to be the final column with

if len(fish_frame.columns) == 4:

del fish_frame[3].

Right before this command, however, I drop all columns of NaNs. So that removes column [3] because it is filled with NaNs, so it fails.

I would like to say just drop the final column of the entire DataFrame. I feel like that would work perfectly.

I tried fish_frame([:-1], axis=1) but that's invalid syntax.

Any help would be appreciated thanks.

The DataFrame:

fish_frame after dropna:

0 1 2 4

0 #0721 NaN NaN NaN

1 GBE COD 746 $2.00 $1,492.00

2 GBW COD 13,894 $0.50 $6,947.00

3 GOM COD 60 $2.00 $120.00

4 GB WINTER FLOUNDER 94,158 $0.25 $23,539.50

5 GOM WINTER FLOUNDER

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值