Is there a Python equivalent to R's sample() function?

Bilal

I want to know if Python has an equivalent to the sample() function in R.

The sample() function takes a sample of the specified size from the elements of x using either with or without replacement.

The syntax is:

sample(x, size, replace = FALSE, prob = NULL)

(More information here)

Julian Wittische

I think numpy.random.choice(a, size=None, replace=True, p=None) may well be what you are looking for.

The p argument corresponds to the prob argument in the sample()function.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Python's equivalent for R's dput() function

From Dev

Python equivalent of R's head and tail function

From Dev

Python equivalent of R "split"-function

From Dev

R equivalent to the Python function "dir"?

From Dev

Equivalent of R's createDataPartition in Python

From Dev

Equivalent of R's removeSparseTerms in Python

From Java

Equivalent of R's factor function in Pandas

From Dev

R: Is there an equivalent of Stata's ibn. function?

From Dev

equivalent of R's View for Python's pandas

From Dev

What is python's equivalent of R's NA?

From Dev

Matlab equivalent of Python's 'reduce' function

From Dev

Is there a Python equivalent to MATLAB's pearsrnd function?

From Dev

Is there an equivalent to Python's all function in JavaScript or jQuery?

From Dev

What is the Java equivalent to Python's reduce function?

From Dev

Pandas equivalent of Python's readlines function

From Dev

Is there an equivalent to Python's exec() function in Java?

From Dev

Equivalent of Python's dir function in PHP

From Dev

Is there a python ReportLab equivalent of TCPDF's 'annotate' function?

From Dev

Is there a C# equivalent to python's type() function?

From Dev

Python equivalent to Matlab's set function

From Dev

What is the Python Equivalent of Batch's PAUSE function

From Dev

Matlab equivalent of Python's 'reduce' function

From Dev

Python numpy or pandas equivalent of the R function sweep()

From Dev

Python equivalent of R apply with anonymous function

From Dev

Equivalent of R function 'ave' in Python Pandas

From Dev

Benchmarking "sample" function in R

From Dev

Does 'statsmodels' or another Python package offer an equivalent to R's 'step' function?

From Dev

Python equivalent for R's 'zoo' package

From Dev

R's read.table equivalent in Python

Related Related

  1. 1

    Python's equivalent for R's dput() function

  2. 2

    Python equivalent of R's head and tail function

  3. 3

    Python equivalent of R "split"-function

  4. 4

    R equivalent to the Python function "dir"?

  5. 5

    Equivalent of R's createDataPartition in Python

  6. 6

    Equivalent of R's removeSparseTerms in Python

  7. 7

    Equivalent of R's factor function in Pandas

  8. 8

    R: Is there an equivalent of Stata's ibn. function?

  9. 9

    equivalent of R's View for Python's pandas

  10. 10

    What is python's equivalent of R's NA?

  11. 11

    Matlab equivalent of Python's 'reduce' function

  12. 12

    Is there a Python equivalent to MATLAB's pearsrnd function?

  13. 13

    Is there an equivalent to Python's all function in JavaScript or jQuery?

  14. 14

    What is the Java equivalent to Python's reduce function?

  15. 15

    Pandas equivalent of Python's readlines function

  16. 16

    Is there an equivalent to Python's exec() function in Java?

  17. 17

    Equivalent of Python's dir function in PHP

  18. 18

    Is there a python ReportLab equivalent of TCPDF's 'annotate' function?

  19. 19

    Is there a C# equivalent to python's type() function?

  20. 20

    Python equivalent to Matlab's set function

  21. 21

    What is the Python Equivalent of Batch's PAUSE function

  22. 22

    Matlab equivalent of Python's 'reduce' function

  23. 23

    Python numpy or pandas equivalent of the R function sweep()

  24. 24

    Python equivalent of R apply with anonymous function

  25. 25

    Equivalent of R function 'ave' in Python Pandas

  26. 26

    Benchmarking "sample" function in R

  27. 27

    Does 'statsmodels' or another Python package offer an equivalent to R's 'step' function?

  28. 28

    Python equivalent for R's 'zoo' package

  29. 29

    R's read.table equivalent in Python

HotTag

Archive