<jupyter_start><jupyter_text>What's the version of NumPy that you installed?<jupyter_code>np.__version__<jupyter_output><empty_output><jupyter_text>What's the version of Pandas?<jupyter_code>pd.__version__
data = pd.read_csv("C:/Users/Shreetama/Desktop/data science learning/data zoomcamp/cars_data.csv")
data.head()
bmw = data[(data["Make"] == "BMW")]

pd.pivot_table(data, values = "MSRP", index = "Make", aggfunc = np.mean)<jupyter_output><empty_output><jupyter_text>What's the average price of BMW cars in the dataset?<jupyter_code>pd.pivot_table(bmw, values = "MSRP", index = "Make", aggfunc = np.mean)<jupyter_output><empty_output><jupyter_text>What's the average price of BMW cars in the dataset?<jupyter_code>pd.pivot_table(data[(data["Make"] == "BMW")], values = "MSRP", index = "Make", aggfunc = np.mean)
cars_2015 = data[(data["Year"] >= 2015)]
np.sum(cars_2015.isna())
mean_hp_before = np.mean(data["Engine HP"])<jupyter_output><empty_output><jupyter_text>Select a subset of cars after year 2015 (inclusive, i.e. 2015 and after). How many of them have missing values for Engine HP? Select a subset of cars after year 2015 (inclusive, i.e. 2015 and after). How many of them have missing values for Engine HP<jupyter_code>np.sum(data["Engine HP"].isna())<jupyter_output><empty_output><jupyter_text>Calculate the average "Engine HP" in the dataset.Use the fillna method and to fill the missing values in "Engine HP" with the mean value from the previous step.Now, calcualte the average of "Engine HP" again.Has it changed?<jupyter_code>data["Engine HP_after"] = data["Engine HP"].fillna(mean_hp_before)
mean_hp_after = np.mean(data["Engine HP_after"])

print(round(mean_hp_before))
print(round(mean_hp_after))

rolls_roy = data[(data["Make"] == "Rolls-Royce")]
rr = rolls_roy[["Engine HP", "Engine Cylinders", "highway MPG"]]
rr_dd = rr.drop_duplicates()
rr_dd.head(8)<jupyter_output><empty_output><jupyter_text>Select all the "Rolls-Royce" cars from the dataset.Select only columns "Engine HP", "Engine Cylinders", "highway MPG".Now drop all duplicated rows using drop_duplicates method (you should get a dataframe with 7 rows).Get the underlying NumPy array. Let's call it X.Compute matrix-matrix multiplication between the transpose of X and X. To get the transpose, use X.T. Let's call the result XTX.Invert XTX.What's the sum of all the elements of the result?Hint: if the result is negative, re-read the task one more time<jupyter_code>X = rr_dd.to_numpy()
X_T = X.transpose()
print(X_T)
XTX = np.matmul(X_T, X)
print(XTX)
XTX_inv = np.linalg.inv(XTX)
print(XTX_inv)
np.sum(XTX_inv)<jupyter_output><empty_output><jupyter_text>Create an array y with values [1000, 1100, 900, 1200, 1000, 850, 1300].Multiply the inverse of XTX with the transpose of X, and then multiply the result by y. Call the result w.What's the value of the first element of w?.<jupyter_code>y = [1000, 1100, 900, 1200, 1000, 850, 1300]
z = np.matmul(XTX_inv, X_T)
w = np.matmul(z, y)
w[0]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12520812520812521, 'fraction_numerical': 0.02763902763902764, 'mean_word_length': 6.380835380835381, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 34, 'https://': 0, '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': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '450442', 'license': 'MIT', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1050, 'n_words': 314, 'path': '1st week homework.ipynb', 'repo_name': '1985shree/Data-science-Zoomcamp-projects', 'size': '3003'}