-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfinal_project.py
60 lines (43 loc) · 2.12 KB
/
final_project.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import wikipedia
import pandas as pd
import matplotlib.pyplot as plt
""" Demonstrates the max value of qubits in an industry. """
# Connect to the wikipedia page to get an url.
quant_comp_page = wikipedia.page("List of quantum processors")
# Pandas module allows to get page's tables as a feature of read_html.
# All we need is a page's url and the table's index.
url = quant_comp_page.url
# Download a table for universlal computer's qubits.
processors_table = pd.read_html(url)[0]
# Also download a table for noisy qubits.
dwave_table = pd.read_html(url)[1]
# Here we use list comprehension to clean the data in the cell.
# We do it by splitting it with a separator=' '.
# And also transform it to the int() in order to find the max value
processors_table['Qubits'] = [int(text.split(' ', 1)[0])
for text in processors_table['Qubits']]
# Creating a new dataframe with beautiful data
processors_df = pd.DataFrame(
processors_table, columns=['Manufacturer', 'Name/Codename/Designation', 'Qubits'])
# Renaming a column name just for the better visualization
processors_df = processors_df.rename(
columns={'Name/Codename/Designation': 'Name'})
# Find the max value of qubits
max_qubits = max(processors_df['Qubits'])
# Create a list of the top quantum computer in the industry
top_quantum_comp = list(*processors_df[processors_df['Qubits']
== max_qubits].values.tolist())
# Perform a similar process for noisy qubits table.
# Here we transform data to int type for qubits.
dwave_table['Qubits'] = [int(text.split(' ', 1)[0])
for text in dwave_table['Qubits']]
# Transform date to int type.
dwave_table['Release date'] = [int(text.split(' ', 2)[-1])
for text in dwave_table['Release date']]
# Cleaning up a little bit our table with D-wave noisy qubits
dwave_df = pd.DataFrame(
dwave_table, columns=['Qubits', 'Release date'])
dwave_df = dwave_df.rename(columns={'Release date': 'Year'})
# Prepare data for export as a list
dwave_qubits = dwave_df['Qubits'].values.tolist()
dwave_year = dwave_df['Year'].values.tolist()