Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

sample datafra,e PYTHON

# divide your data by 2 
df.sample(frac=0.5, replace=True, random_state=1)
Comment

sample data frame in python

import pandas as pd
sentence = 'The quick brown fox jumps over a lazy dog.'
words = sentence.split(' ')
df1 = pd.DataFrame({'key': range(len(words)),
                     'column1_Words': words,
                     'column2_Length': [len(x) for x in words]
                     })
>>> df1
   key column1_Words  column2_Length
0    0           The               3
1    1         quick               5
2    2         brown               5
3    3           fox               3
4    4         jumps               5
5    5          over               4
6    6             a               1
7    7          lazy               4
8    8          dog.               4
Comment

pandas df sample

df['num_legs'].sample(n=3, random_state=1)
Comment

pandas create sample dataframe

>>> import pandas as pd
>>> sentence = 'The quick brown fox jumps over a lazy dog.'
>>> words = sentence.split(' ')
>>> df1 = pd.DataFrame({'key': range(len(words)),
...                     'column1_Words': words,
...                     'column2_Length': [len(x) for x in words]
...                     })
>>> df1
   key column1_Words  column2_Length
0    0           The               3
1    1         quick               5
2    2         brown               5
3    3           fox               3
4    4         jumps               5
5    5          over               4
6    6             a               1
7    7          lazy               4
8    8          dog.               4
>>> 
Comment

PREVIOUS NEXT
Code Example
Python :: Read the entire text file using the read() function 
Python :: tkinter maximise window 
Python :: panda python 
Python :: compile python to exe bash 
Python :: python convert string to list 
Python :: count non nan values in column 
Python :: float 2 decimals jupyter 
Python :: create app in a django project 
Python :: rotate 2d array 
Python :: Write byte data in file python 
Python :: batch gradient descent 
Python :: how to make tkinter look better 
Python :: add 1 to all columns in numpy array 
Python :: python discord bot 
Python :: pyhton map 
Python :: how to handle multiple frames 
Python :: open file with python 
Python :: invert list python 
Python :: python log file 
Python :: stegano python 
Python :: concatenation array 
Python :: Flatten List in Python Using NumPy Reshape 
Python :: python dictionary comprehensions 
Python :: drop column of datfame 
Python :: unsplash python 
Python :: push notification using python 
Python :: xarray get number of lat lon 
Python :: sort python 
Python :: python decorator 
Python :: how to copy the list in python 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =