Jupyter笔记本中的感叹号和问号是什么意思?

约尔·扎亚克(Yoel Zajac)

我想知道以下表达式的含义,尤其是!and的含义?,在以下示例中,与查询Pandas DataFrame中的数据有关:

感叹号:

  • !cat olympics.csv

问号):

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

这两个标记都可以在Jupyter笔记本中使用

感叹号!用于执行来自操作系统的命令;这是使用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  

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

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

ES6进口-感叹号是什么意思?

JavaScript中变量后的感叹号是什么意思?

在C#8.0中调用方法之前,感叹号是什么意思?

在Swift语言中,感叹号是什么意思?

Eclipse中的红色感叹号图标是什么意思?

在Haskell声明中,感叹号是什么意思?

单元格引用之前的感叹号是什么意思?

特质实施中的感叹号是什么意思?

SASS导入后的感叹号是什么意思?

函数名称后的感叹号是什么意思?

Fsharp / FAKE中的双感叹号(!!)是什么?

In [num]在jupyter笔记本中是什么意思?

!(感叹号)在javascript中之前和之后是什么意思?

在班级名称前面的播放测试图标附近,感叹号是什么意思。浓咖啡。测试中

感叹号在对象表示中的含义是什么

在函数调用之前,感叹号是什么意思?

“ git show-branch”中的感叹号是什么意思?

Eclipse中的红色感叹号图标是什么意思?(图标在右侧,而不是左侧)

实习生定义中的感叹号是什么意思?

以下bash命令中的!#(感叹号哈希),!$:r:r(感叹号美元冒号r),!#:t(感叹号冒号冒号t)是什么意思?

diff输出中的感叹号是什么意思?

Windows 8.1 Mail App中的感叹号是什么意思?

布局文件中的红色感叹号是什么意思?

udev规则中的感叹号是什么意思?

这里的感叹号是什么意思

linux命令中方括号后跟感叹号是什么意思?

Jupyter 笔记本感叹号参数

Android Studio:设备下拉列表中的红色感叹号是什么意思?

linux中感叹号是什么意思?