[英]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.