简体   繁体   English

TypeError: with_column() 从 3 到 4 个位置 arguments 但给出了 5 个(python)

[英]TypeError: with_column() takes from 3 to 4 positional arguments but 5 were given (python)

I have been having issue with the limits of positional arguments in jupyter notebook.我一直对 jupyter 笔记本中位置 arguments 的限制有疑问。 Im trying to To get a sense of the variability in the number of heads in 100 tosses, we can collect the results in a table and draw a histogram.我试图了解 100 次投掷中正面数量的变化,我们可以将结果收集在表格中并绘制直方图。

         simulation_results = Table().with_column(
        'Repetition', np.arange(1, num_repetitions + 1),
        'Number of Heads', heads
    )
    
    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    <ipython-input-15-484d76c43683> in <module>
    ----> 1 simulation_results = Table().with_column(
          2     'Repetition', np.arange(1, num_repetitions + 1),
          3     'Number of Heads', heads
          4 )
    
    TypeError: with_column() takes from 3 to 4 positional arguments but 5 were given

with_column() can add or replace only one column at a time, so rewrite it to: with_column()一次只能添加或替换一列,因此将其重写为:

simulation_results = Table().with_column(
  'Repetition', np.arange(1, num_repetitions + 1)
)
simulation_results = simulation_results.with_column(
  'Number of Heads', heads
)

or或者

simulation_results = Table()
.with_column('Repetition', np.arange(1, num_repetitions + 1))
.with_column('Number of Heads', heads)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python TypeError:接受 4 个位置参数,但给出了 5 个 - Python TypeError: takes 4 positional arguments but 5 were given Python/MySQL TypeError:execute() 需要 2 到 4 个位置参数,但给出了 5 个 - Python/MySQL TypeError: execute() takes from 2 to 4 positional arguments but 5 were given Python TypeError:衍生物_circ()接受2个位置参数,但给出了6个 - Python TypeError: derivatives_circ() takes 2 positional arguments but 6 were given TypeError:__init __()接受2个位置参数,但是给了3个Python 3? - TypeError: __init__() takes 2 positional arguments but 3 were given Python 3? 类型错误:update() 需要 2 个位置参数,但给出了 3 个:Python - TypeError: update() takes 2 positional arguments but 3 were given : Python Python - TypeError: generateID() 需要 3 个位置 arguments 但给出了 4 个 - Python - TypeError: generateID() takes 3 positional arguments but 4 were given python super:TypeError:__init __()接受2个位置参数,但给出了3个 - python super :TypeError: __init__() takes 2 positional arguments but 3 were given 类型错误:__call__() 需要 1 到 2 个位置参数,但给出了 3 个 - TypeError: __call__() takes from 1 to 2 positional arguments but 3 were given TypeError:__init __()从1到2个位置参数,但给出了3个 - TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given TypeError:match()接受2到3个位置参数,但给出了5个 - TypeError: match() takes from 2 to 3 positional arguments but 5 were given
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM