1. Engineering
  2. Computer Science
  3. python question i compiler the code and figure out i...

Question: python question i compiler the code and figure out i...

Question details

【Python Question】: I compiler the code, and figure out I cannot get rid of dic_keys and dic_values

【info.json】: {"Albert Einstein": "02/17/1659", "Benjamin Franklin": "02/17/1706", "Ada Lovelace": "02/19/1853", "Zedong Mao": "03/10/1900", "Enlai Zhou": "05/19/1911", "Stephen Hawking": "09/17/1942", "Sir Isaac Newton": "12/17/1643", "Jane Goodall": "11/17/1884", "Madame Curie": "10/17/1867", "Charles Darwin": "09/17/1809", "George Washington Carver": "04/17/1864", "Neil deGrasse Tyson": "05/17/1689", "Michio Kaku": "02/24/1947", "Dian Fossey": "07/17/1932"}

【my_code】

import json
from bokeh.plotting import figure, show, output_file
from collections import Counter

with open('info.json', 'r') as f:
mydict = json.load(f)

months = []
for keys, values in mydict.items():
months.append(values.split('/')[0])

x = []
x.append(Counter(months).keys())
y = []
y.append(Counter(months).values())

output_file('plot.html')

p = figure()

p.vbar(x=x, top=y, width=0.5)

show(p)

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution