小编Rom*_*omB的帖子

在文档字符串 sphinx 中添加字典键

为字典的键添加文档字符串的推荐方法是什么?我正在使用 python 2.7 和 Sphinx。

例如,在下面的代码中,我应该如何提及 my_dict 的键“a”和“b”?(但也许没有必要详细介绍):

def my_func(my_dict):
    """
    :param dict {'a': float, 'b': str} my_dict: description of param
    """
    pass
Run Code Online (Sandbox Code Playgroud)

我的 Pycharm 编辑器似乎无法识别上面的实现

编辑:我也读过这篇文章,但答案没有提到如何指定键的“名称”

python dictionary docstring python-sphinx

5
推荐指数
0
解决办法
1861
查看次数

pandas DataFrame的combine_first方法将布尔值转换为浮点数

我遇到了一个奇怪的问题,其中 merge_first 方法导致存储为 bool 的值向上转换为 float64。例子:

In [1]: import pandas as pd

In [2]: df1 = pd.DataFrame({"a": [True]})

In [3]: df2 = pd.DataFrame({"b": ['test']})

In [4]: df2.combine_first(df1)
Out[4]:
     a     b
0  1.0  test
Run Code Online (Sandbox Code Playgroud)

这个问题已经在3年前的一篇文章中报告过:pandas DataFrame的combine_first和update方法有奇怪的行为。这个问题被告知要解决,但我在 pandas 0.18.1 下仍然有这种行为

感谢您的帮助

python dataframe pandas

4
推荐指数
1
解决办法
1545
查看次数