21. Pandas Sampling DataFrame - random rows selection and grouping

Опубликовано: 29 Сентябрь 2024
на канале: Softhints - Python, Linux, Pandas
2,977
36

Pandas - Random Sample of a subset of a DataFrame - rows or columns

https://blog.softhints.com/pandas-ran...

Step 1: Random sampling of rows(columns) from DataFrame by sample()
Step 2: Get random rows with np.random.choice
Step 3: Random sample of rows based on column value
Step 4: Conditional DataFrame sampling with numpy and weights
Step 5: Pandas sample rows by group
Bonus: Pandas DataFrame combine head() and tail()


---------------------------------------------------------------------------------------------------------------------------------------------------------------
Code store

github: https://github.com/softhints/python/
bitbucket: https://bitbucket.org/softhints/

Socials

site: https://softhints.com/
Facebook:   / 435421910242028  
Facebook:   / softhints  
Twitter:   / softwarehints  
Discord:   / discord