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 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 :: pygame.key.get_pressed() 
Python :: save a seaborn heatmap 
Python :: python filename without extension 
Python :: The following code shows how to reset the index of the DataFrame and drop the old index completely: 
Python :: how to keep columns in pandas 
Python :: python module with alphabet list 
Python :: python sum of natural numbers recursion 
Python :: how to slice dataframe based on daterange in pandas 
Python :: read pickle file python 
Python :: open text with utf-8 
Python :: plotly backend pandas 
Python :: spark add column to dataframe 
Python :: python write txt utf8 
Python :: python argparse include default information 
Python :: numpy compute mad 
Python :: take input in 2d list in python 
Python :: python way to unindent blocks of code 
Python :: drop rows with null date in pandas 
Python :: pip install vlc 
Python :: column contains substring python 
Python :: python - show repeted values in a column 
Python :: pandas convert date to quarter 
Python :: get last day of month python 
Python :: flask db migrate 
Python :: how to click on button using python 
Python :: plotly update legend title 
Python :: python __gt__ 
Python :: list of files to zip python 
Python :: python string to hex 
Python :: where to import kivy builder 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =