create_visuals.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import pandas as pd
  2. import plotly.graph_objects as go
  3. import plotly.offline as pyo
  4. import plotly.io as pio
  5. data = pd.read_csv('data/aggregate/aggregate.csv')
  6. location_counts = data['location'].value_counts(sort=True)
  7. location_fig = go.Figure(data=go.Bar(x=location_counts.index, y=location_counts.values))
  8. location_fig.update_layout(title_text='Location counts', xaxis_title='index', yaxis_title='values')
  9. demand={
  10. "python developer": 7947,
  11. "data analyst": 5221,
  12. "machine learning engineer": 27829,
  13. "software engineer": 46596,
  14. "backend developer": 18583,
  15. "devops engineer": 1785,
  16. "automation engineer": 12976,
  17. "network engineer": 10513,
  18. "vuejs developer": 1444,
  19. "react developer": 6112,
  20. "nodejs developer": 4883,
  21. "frontend developer": 12399,
  22. "full stack developer": 7006,
  23. "ui developer": 9303,
  24. "web application developer": 19582,
  25. "javascript engineer": 6797,
  26. "mobile app developer": 4191,
  27. }
  28. demand = pd.DataFrame.from_dict(demand, orient = 'index', columns=['demand'])
  29. demand.reset_index(inplace=True)
  30. demand.columns=['Query','Demand']
  31. demand_fig = go.Figure(data=go.Bar(x=demand['Query'], y=demand['Demand']))
  32. demand_fig.update_layout(title_text='Job Demand', xaxis_title='Job', yaxis_title='Demand')
  33. graph_div = pyo.plot(demand_fig, output_type='div')
  34. with open('static/demand.html','w') as f:
  35. f.write(graph_div)
  36. pio.write_image(demand_fig,'static/job_demand.png')
  37. pio.write_image(location_fig, 'static/location_counts.png')