• Pandas中常用的魔法命令与Linux命令


    import numpy as np
    import time as time
    
    • 1
    • 2
    1、运行外部python文件(默认是当前目录,最好加上绝对路径)
    %run helloworld.py
    
    • 1
    2、运行代码计时
    # 统计单次运行时间
    %time 2**10
    
    • 1
    • 2

    CPU times: user 5 µs, sys: 2 µs, total: 7 µs
    Wall time: 13.1 µs

    1024

    # 统计多次平均时间
    %timeit 2**10
    
    • 1
    • 2

    4.03 ns ± 0.00531 ns per loop (mean ± std. dev. of 7 runs, 100,000,000 loops each)

    # 可以统计多行平均运行时间
    %%timeit
    2**10
    2**2
    
    • 1
    • 2
    • 3
    • 4

    4.06 ns ± 0.00564 ns per loop (mean ± std. dev. of 7 runs, 100,000,000 loops each)

    3、查看所有变量与函数
    %who
    
    • 1

    np time

    %whos
    
    • 1

    Variable Type> Data/Info

    np>> module>kages/numpy/init.py’>
    time> module>

    %who_ls
    
    • 1

    [‘np’, ‘time’]

    4、更多魔法命令
    %lsmagic
    
    • 1

    Available line magics:
    %alias %alias_magic %autoawait %autocall %automagic %autosave %bookmark %cat %cd %clear %colors %conda %config %connect_info %cp %debug %dhist %dirs %doctest_mode %ed %edit %env %gui %hist %history %killbgscripts %ldir %less %lf %lk %ll %load %load_ext %loadpy %logoff %logon %logstart %logstate %logstop %ls %lsmagic %lx %macro %magic %man %matplotlib %mkdir %more %mv %notebook %page %pastebin %pdb %pdef %pdoc %pfile %pinfo %pinfo2 %pip %popd %pprint %precision %prun %psearch %psource %pushd %pwd %pycat %pylab %qtconsole %quickref %recall %rehashx %reload_ext %rep %rerun %reset %reset_selective %rm %rmdir %run %save %sc %set_env %store %sx %system %tb %time %timeit %unalias %unload_ext %who %who_ls %whos %xdel %xmode

    Available cell magics:
    %%! %%HTML %%SVG %%bash %%capture %%debug %%file %%html %%javascript %%js %%latex %%markdown %%perl %%prun %%pypy %%python %%python2 %%python3 %%ruby %%script %%sh %%svg %%sx %%system %%time %%timeit %%writefile

    Automagic is ON, % prefix IS NOT needed for line magics.

    Linux命令

    在Linux指令之前加上!,即可在ipython当中执行Linux指令

    !pwd
    
    • 1

    /Users/yangchuo/学习/Pandas

    !echo 'hello'
    
    • 1

    hello

  • 相关阅读:
    【背包问题】基于禁忌搜索算法求解背包问题附Matlab代码
    青龙面板从0到1的实现
    五种I/O模型
    Springboot整合Redis的Cluster集群进行API限流
    LeetCode回溯算法组合问题——216.组合总和III
    odoo xmlrpc的用法及实例(二)
    MySQL之账号管理
    用python纯手写一个日历
    C语言 L1-016 查验身份证
    vue常见的指令
  • 原文地址:https://blog.csdn.net/weixin_47744974/article/details/127863317