博客
关于我
dataframe中axisk轴的意思
阅读量:656 次
发布时间:2019-03-15

本文共 464 字,大约阅读时间需要 1 分钟。

要删除 pandas 数据框中的两列 TimeAmount,并沿着轴=1(即列]进行操作,可以通过以下步骤实现:

  • 创建数据框 df,并将其包含的数据转换为字典的形式:
  • data = {    'k1': ['o', 'm'],    'year': [2000, 2001],    'pop': [3.5, 6.5]}df = pd.DataFrame(data)
    1. 使用 drop 方法删除指定的两列:
    2. # 删除 'Time' 和 'Amount' 两列df.drop(columns=['Time', 'Amount'])
      1. 检查删除后的数据框:
      2. print(df)

        这一方法通过在 columns 参数中指定需要删除的列名,直接实现垂直方向上的数据截取,不会受到列名唯一性的影响。需要注意的是,要确保删除的列名与数据框的当前列名匹配。如果有参数错误或版本问题,可以使用 df.drop(columns=[...]) 这种更直接的方式。

        通过这种方式,可以依靠 pandas 的强大功能简化操作,并确保数据处理的准确性。

    转载地址:http://atrmz.baihongyu.com/

    你可能感兴趣的文章
    No new migrations found. Your system is up-to-date.
    查看>>
    No qualifying bean of type XXX found for dependency XXX.
    查看>>
    No resource identifier found for attribute 'srcCompat' in package的解决办法
    查看>>
    no session found for current thread
    查看>>
    No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
    查看>>
    NO.23 ZenTaoPHP目录结构
    查看>>
    NO32 网络层次及OSI7层模型--TCP三次握手四次断开--子网划分
    查看>>
    NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
    查看>>
    Node JS: < 一> 初识Node JS
    查看>>
    Node-RED中使用JSON数据建立web网站
    查看>>
    Node-RED中使用json节点解析JSON数据
    查看>>
    Node-RED中使用node-random节点来实现随机数在折线图中显示
    查看>>
    Node-RED中使用node-red-browser-utils节点实现选择Windows操作系统中的文件并实现图片预览
    查看>>
    Node-RED中使用node-red-node-ui-iframe节点实现内嵌iframe访问其他网站的效果
    查看>>
    Node-RED中使用Notification元件显示警告讯息框(温度过高提示)
    查看>>
    Node-RED中实现HTML表单提交和获取提交的内容
    查看>>
    Node.js 8 中的 util.promisify的详解
    查看>>
    Node.js 函数是什么样的?
    查看>>
    Node.js 历史
    查看>>
    Node.js 在个推的微服务实践:基于容器的一站式命令行工具链
    查看>>