import
numpy as np
import
pandas as pd
import
random
number_of_house
=
30
data
=
{
'house_number'
: [
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
,
20
,
21
,
22
,
23
,
24
,
25
,
26
,
27
,
28
,
29
,
30
],
'number_of_children'
: [
2
,
2
,
1
,
3
,
2
,
1
,
4
,
1
,
3
,
5
,
4
,
3
,
5
,
3
,
2
,
1
,
2
,
3
,
4
,
5
,
3
,
4
,
5
,
2
,
2
,
2
,
2
,
3
,
2
,
1
]}
df
=
pd.DataFrame(data)
size_of_systematic_sample
=
6
interval
=
(number_of_house
/
/
size_of_systematic_sample)
random_number
=
random.randint(
1
,
30
)
def
systematic_sampling(df, step):
indexes
=
np.arange(random_number,
len
(df), step
=
step)
systematic_sample
=
df.iloc[indexes]
return
systematic_sample
systematic_sample
=
systematic_sampling(df, interval)
display(systematic_sample)
print
()
systematic_data
=
round
(systematic_sample[
'number_of_children'
].mean())
print
(
"Average Number Of Childrens in Locality: "
, systematic_data)