1>>> df.sample(frac=0.5, replace=True, random_state=1)
2 num_legs num_wings num_specimen_seen
3dog 4 0 2
4fish 0 0 8
5
1>>> df['num_legs'].sample(n=3, random_state=1)
2fish 0
3spider 8
4falcon 2
5Name: num_legs, dtype: int64
6
1>>> df = pd.DataFrame({'num_legs': [2, 4, 8, 0],
2... 'num_wings': [2, 0, 0, 0],
3... 'num_specimen_seen': [10, 2, 1, 8]},
4... index=['falcon', 'dog', 'spider', 'fish'])
5>>> df
6 num_legs num_wings num_specimen_seen
7falcon 2 2 10
8dog 4 0 2
9spider 8 0 1
10fish 0 0 8
11
1>>> import pandas as pd
2>>> sentence = 'The quick brown fox jumps over a lazy dog.'
3>>> words = sentence.split(' ')
4>>> df1 = pd.DataFrame({'key': range(len(words)),
5... 'column1_Words': words,
6... 'column2_Length': [len(x) for x in words]
7... })
8>>> df1
9 key column1_Words column2_Length
100 0 The 3
111 1 quick 5
122 2 brown 5
133 3 fox 3
144 4 jumps 5
155 5 over 4
166 6 a 1
177 7 lazy 4
188 8 dog. 4
19>>>