From the docs for c
it is used to
Combine Values into a Vector or List
In python you can combine values into a list using brackets so c(1, 2, 3)
in R become [1, 2, 3]
in Python. But if you didn't know this, I really urge you to stop porting the code and take two days to go through a basic Python tutorial. Understanding lists in Python is about as basic as you get.
The docs for tabulate
state
tabulate
takes the integer-valued vectorbin
and counts the number of times each integer occurs in it.
this sounds just like numpy's bincount
Count number of occurrences of each value in array of non-negative ints.
unless you have a requirement to also count negative ints? If not, it's pretty much a drop in replacement. So tabulate(c(2,3,3,5), nbins = 10)
becomes np.bincount(np.array([2, 3, 3, 5]), minlength=10)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.