<jupyter_start><jupyter_text>Working with Spatial Data and Networks Lab ShapefileA shapefile actually consists of three files with different extensions. Each of these contains different information about the objects that are in the file. Which file contains a dataset containing information about the shapes? Write the file extension (three letters, with or without the leading dot, e.g. "txt" or ".txt").The answer is ".dbf" - see Wikipedia Choice of AlgorithmsWhich of the following algorithms best matches the following description? "Given a set of points P and a number k, the algorithm separates the points into k different clusters. Each point from P is assigned a unique cluster." Fun side note: All these algorithms start with "k" and are related to spatial data processing :)The answer is "K-means" - see Wikipedia Coordinate ConversionThe code below draws a map of Bulgaria. On it, we need to draw a dot where Sofia is, using the coordinates given in the variable "sofia". To do this, we need to convert them to Cartesian coordinates. The function call contains two unknown parameters, replaced by "???". They both should reference the "sofia" variable. What is the value of the first parameter?<jupyter_code>sofia = {"lat": 42.6977, "lng": 23.3219}
plt.figure(figsize = (12, 10))
m = Basemap(projection = "merc", llcrnrlat = 41, llcrnrlon = 22, urcrnrlat = 44.5, urcrnrlon = 29, resolution = "i")
m.drawcoastlines()
m.drawcountries()

x, y = m(sofia["lng"], sofia["lat"])
m.plot(x, y, "o")

plt.show()<jupyter_output><empty_output><jupyter_text>Florentine FamiliesOne famous graph in social network analysis is the "Florentine families" graph. It is implemented by default in networkx. Each node represents a family, each edge - a marital relationship (i.e. someone from family A married someone from family B). Since marriage is mutual (at least, it should be :D), the graph is undirected. Load it (and visualize it if you want). How many nodes does the shortest path from Pazzi to Peruzzi contain, including the starting and the final one?<jupyter_code>florentine_families = nx.florentine_families_graph()
nx.draw_networkx(florentine_families, with_labels = True)
plt.show()
nx.shortest_path(florentine_families, "Pazzi", "Peruzzi")
len(nx.shortest_path(florentine_families, "Pazzi", "Peruzzi"))<jupyter_output><empty_output><jupyter_text>A Famous FamilyWhat is the name of the most important / famous family in this graph? Use code to see this, not your imagination :D.<jupyter_code>centrality = nx.betweenness_centrality(florentine_families)
key_list = list(centrality.keys())
val_list = list(centrality.values())
position = val_list.index(max(val_list))
print(key_list[position])<jupyter_output>Medici
{'fraction_non_alphanumeric': 0.08428413691571586, 'fraction_numerical': 0.009201324990798674, 'mean_word_length': 5.694581280788177, 'pattern_counts': {'":': 2, '<': 12, '<?xml version=': 0, '>': 12, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '198091', 'license': 'MIT', 'n_tokens_mistral': 833, 'n_tokens_neox': 781, 'n_words': 339, 'path': 'working_with_spatial_data_network_analysis/Spatial Data and Networks Quiz.ipynb', 'repo_name': 'PetkoAndreev/Python-Data-Science', 'size': '2717'}