<jupyter_start><jupyter_text>Imputing missing values<jupyter_code>URL = 'https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data'
df = pd.read_csv(URL, names=['sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'class'])

# Randomly select 10 rows
random_index = np.random.choice(df.index, replace=False, size=10)

# Set the sepal_length values of the rows to be None
df.loc[random_index, 'sepal_length'] = None
df.isnull().any()
# droping the missing value row from data frame
print("Number of rows before deleting: %d" %(df.shape[0]))
df2 = df.dropna()
print("Number of rows before deleting: %d" %(df2.shape[0]))
# imputing missing value using mean
df.sepal_length = df.sepal_length.fillna(df.sepal_length.mean())
df.isnull().any()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15063291139240506, 'fraction_numerical': 0.010126582278481013, 'mean_word_length': 6.462264150943396, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '413470', 'license': 'MIT', 'n_tokens_mistral': 294, 'n_tokens_neox': 288, 'n_words': 65, 'path': 'Iris_dataset_problem/encoding_categorical_variables.ipynb', 'repo_name': 'Rezwanul-Haque/neural_network_projects', 'size': '790'}