Jupyter Notebook 中的感叹号和问号是什么意思?

2024-02-17

下列词语的含义是什么,尤其是! and ?,在以下示例中,与查询 Pandas DataFrame 中的数据相关:

感叹号:

  • !cat olympics.csv

问号):

  • df.fillna?
  • import pandas as pd pd.Series?
  • copy_df.drop?

这两个标记都可以在 Jupyter Notebook 中使用。

感叹号,!,用于执行来自底层操作系统的命令;这是一个使用 Windows 的示例dir:

!dir
# Result:
Volume in drive C has no label.
 Volume Serial Number is 52EA-B90C

 Directory of C:\Users\Root

27/11/2018  13:08    <DIR>          .
27/11/2018  13:08    <DIR>          ..
23/08/2016  11:00             2,258 .adalcache
12/09/2016  18:06    <DIR>          .anaconda
[...]

问题?标记用于提供笔记本内帮助:

import pandas as pd
import numpy as np

df = pd.DataFrame([[np.nan, 2, np.nan, 0],
                   [3, 4, np.nan, 1],
                   [np.nan, np.nan, np.nan, 5],
                   [np.nan, 3, np.nan, 4]],
                   columns=list('ABCD'))

df.fillna?

Result:

Signature: df.fillna(value=None, method=None, axis=None, inplace=False, limit=None, downcast=None, **kwargs)
Docstring:
Fill NA/NaN values using the specified method

Parameters
----------
value : scalar, dict, Series, or DataFrame
    Value to use to fill holes (e.g. 0), alternately a
    dict/Series/DataFrame of values specifying which value to use for
    each index (for a Series) or column (for a DataFrame). (values not
    in the dict/Series/DataFrame will not be filled). This value cannot
    be a list.
method : {'backfill', 'bfill', 'pad', 'ffill', None}, default None
    Method to use for filling holes in reindexed Series
    pad / ffill: propagate last valid observation forward to next valid
    backfill / bfill: use NEXT valid observation to fill gap
axis : {0, 1, 'index', 'columns'}
inplace : boolean, default False
    If True, fill in place. Note: this will modify any
    other views on this object, (e.g. a no-copy slice for a column in a
    DataFrame).
limit : int, default None
    If method is specified, this is the maximum number of consecutive
    NaN values to forward/backward fill. In other words, if there is
    a gap with more than this number of consecutive NaNs, it will only
    be partially filled. If method is not specified, this is the
    maximum number of entries along the entire axis where NaNs will be
    filled.
downcast : dict, default is None
    a dict of item->dtype of what to downcast if possible,
    or the string 'infer' which will try to downcast to an appropriate
    equal type (e.g. float64 to int64 if possible)

See Also
--------
reindex, asfreq

Returns
-------
filled : DataFrame
File:      c:\users\root\anaconda3\lib\site-packages\pandas\core\frame.py
Type:      method

现在应该很清楚了,这些标记都不是 pandas 特有的:

np.argmax?

Result:

Signature: np.argmax(a, axis=None, out=None)
Docstring:
Returns the indices of the maximum values along an axis.

Parameters
----------
a : array_like
    Input array.
axis : int, optional
    By default, the index is into the flattened array, otherwise
    along the specified axis.
out : array, optional
    If provided, the result will be inserted into this array. It should
    be of the appropriate shape and dtype.

Returns
-------
index_array : ndarray of ints
    Array of indices into the array. It has the same shape as `a.shape`
    with the dimension along `axis` removed.

See Also
--------
ndarray.argmax, argmin
amax : The maximum value along a given axis.
unravel_index : Convert a flat index into an index tuple.

Notes
-----
In case of multiple occurrences of the maximum values, the indices
corresponding to the first occurrence are returned.

Examples
--------
>>> a = np.arange(6).reshape(2,3)
>>> a
array([[0, 1, 2],
       [3, 4, 5]])
>>> np.argmax(a)
5
>>> np.argmax(a, axis=0)
array([1, 1, 1])
>>> np.argmax(a, axis=1)
array([2, 2])

>>> b = np.arange(6)
>>> b[1] = 5
>>> b
array([0, 5, 2, 3, 4, 5])
>>> np.argmax(b) # Only the first occurrence is returned.
1
File:      c:\users\root\anaconda3\lib\site-packages\numpy\core\fromnumeric.py
Type:      function
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Jupyter Notebook 中的感叹号和问号是什么意思? 的相关文章

随机推荐

  • 预配对蓝牙设备

    我希望能够预先配对蓝牙设备 以避免用户在使用应用程序时感到困惑的步骤 我发现有一项专利用于预配对蓝牙设备的系统 方法和装置 http www google com patents US20070123166 我正在考虑将一组 Android
  • fork() 时文件描述符是否共享?

    假设我打开一个文件open 然后我fork 我的程序 父亲和孩子现在会共享文件描述符的相同偏移量吗 我的意思是 如果我在父亲中写入 孩子中的偏移量也会改变吗 或者偏移量在之后将是独立的fork From fork 2 The child i
  • 我的 PHP 文档中的 `$page -= 1` 是什么意思? [复制]

    这个问题在这里已经有答案了 我在正在使用的 PHP 文档中定义了以下变量 但我不确定它的含义 The PHP page 1 我不确定的部分是 这是节省打字的简写 其效果等同于 page page 1
  • CSS 网格自动流如何工作?

    我面临的问题是我不明白隐式网格是如何工作的 我阅读了文档 MDN 和更多资源 但还有一个悬而未决的问题 grid display grid grid template repeat 2 100px repeat 6 1fr grid gap
  • BERT 分词器和模型下载

    我是初学者 我正在和伯特一起工作 但出于公司网络的安全考虑 下面的代码并没有直接接收bert模型 tokenizer BertTokenizer from pretrained bert base multilingual cased do
  • 如何用递归的方式思考?

    为了理解贪婪方法和动态规划等高级算法概念 首先需要精通递归 我对递归比较陌生 每当提出问题时 首先想到的就是使用迭代的解决方案 尽管我知道递归方法的含义及其工作原理 但以递归方式思考还是非常困难 请帮助回答以下问题 1 任何迭代方法都可以用
  • 如何在 eclipse luna 中配置 lombok

    我使用 Maven 在 eclipse Luna 中配置 lombok 注解已正确添加 但未生成 getter 和 setter eclipse ini vm E Program Files Java jdk1 7 0 60 bin vma
  • 如何拆分长 GraphQL 模式

    我正在尝试创建一个架构 但是会变得太长且令人困惑 分割不同查询 突变和输入的最佳实践是什么 这样我就可以只需要它们并组织它们以使其易于阅读 我试图在网上查找信息 但没有任何明确的信息 我试图不使用阿波罗 const buildSchema
  • 对可变长度序列进行训练和预测

    传感器 同类型的 分散在我的网站上 不定期地手动向我的后端报告 在报告之间 传感器聚合事件并批量报告它们 以下数据集是批量收集的序列事件数据的集合 例如传感器 1 报告了 2 次 在第一批 2 个事件和第二批 3 个事件中 传感器 2 报告
  • 修复 file_get_contents 权限被拒绝的错误

    我有一个关于 JSON 和 PHP 的问题 因此 如果您访问此网站 作为返回 您会得到 HTML 但如果您转到响应 则响应是纯 JSON 因此我尝试获取 JSON 数据 但失败了 也许我做错了什么 但我不知道是什么 我尝试过file get
  • 使用 jmxagent 将 Spark Worker/Executor 指标导出到 Prometheus

    我已按照说明进行操作here https argus sec com monitoring spark prometheus 启用指标导出到 Prometheus for Spark 为了不仅可以从作业中导出指标 还可以从主控器和工作器中导
  • React Dev Tools 不显示组件名称或状态变量名称

    这是 Google Chrome 中新的 React 开发工具的屏幕截图 仅顶级组件名称AdminArea显示 该组件位于我的脚本的入口文件中 index jsx 还应该有 AddNewCoupon 和 ViewCoupons 组件 没有启
  • 这个 Ruby 类方法是如何被调用的?

    在屏幕投射中从 Rails 应用程序导出 CSV http railscasts com episodes 362 exporting csv and excel Ryan Bates 给出了以下简单的代码 我试图弄清楚类方法 Produc
  • Sublime Text 3 中包的语法高亮 (.tmLanguage)

    我正在研究这个plugin https github com andriyko sublime robot framework assistant 使用包控制安装插件时 语法突出显示不适用于 Sublime Text 3 Error loa
  • WPF 的自定义复选框样式

    我想将 wpf 默认复选框设置为自定义的外观 由于开始一个全新的控件并没有真正的意义 因此我想覆盖复选框的 Bulletchrome 子组件的 Windows Chrome 模板绑定 但是 我不能像使用复选框那样做到这一点 尝试使用类似的东
  • 如何使用 Android 的 ListView 在 React Native 中实现上拉加载更多内容?

    这就像下拉刷新的相反操作 Android 上的 ListView 不支持弹跳 实现无限滚动ListView您可以使用onEndReached and renderFooter from ListView成分 它可能看起来像这样 你只需ren
  • 立即绘制和 Matplotlib

    我目前正在开展一个项目 该项目涉及获取模拟读数并将其实时映射到图表上 因此 为了完成此任务 我通过 Arduino 模拟端口运行光敏电阻 并通过 python 3 4 3 读取该数据 在Python方面 我安装了maplotlib和draw
  • 使用 sendKeys() 在 Selenium 中上传文件不起作用

    我无法使用上传文件sendKeys 这是我的代码 driver findElement By xpath Locators browseFlagIconBtn sendKeys D Images icons png 我有一个用于文件上传的文
  • Spring 和 Hibernate 的正确版本以及所需的依赖项...由于依赖项而出现异常

    三天以来 我一直在尝试运行我的 Spring Hibernate 程序 由于 hibernate2 和 hibernate3 之间的版本差异 我很难找到所涉及的依赖项 最后我能够运行具有以下依赖项的程序 cglib nodep 2 1 3
  • Jupyter Notebook 中的感叹号和问号是什么意思?

    下列词语的含义是什么 尤其是 and 在以下示例中 与查询 Pandas DataFrame 中的数据相关 感叹号 cat olympics csv 问号 df fillna import pandas as pd pd Series co