NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import pandas as pd
import numpy as np
import plotly.express as px

# Sample data for demonstration purposes
np.random.seed(42)
weeks = list(range(1, 53))
departments = ['Department A', 'Department B', 'Department C']
status = ['Approved', 'Processing', 'Canceled']
violation_types = ['Speeding', 'Parking', 'Parking Reverse', 'Failing to Stop', 'Wrong Turn']
categories = ['Warning', 'Violation', 'Government Violation']
area = ['Dammam', 'Jeddah', 'Riyadh', 'Jubail Highway', 'DM Airport', 'Inside Camp']
sources = ['Security Man', 'Camera']
security_men = ['John Doe', 'Abdulwahid Alhemod', 'Jane Smith', 'Sam Brown', 'Faisal Alhemeli']
security_departments = ['Security Department 1', 'Security Department 2']

# Generate random data for each chart
data = {
'Week': np.random.choice(weeks, 500),
'Department': np.random.choice(departments, 500),
'Status': np.random.choice(status, 500),
'Violation Type': np.random.choice(violation_types, 500),
'Source': np.random.choice(sources, 500),
'Security Man': np.random.choice(security_men, 500),
'Security Department': np.random.choice(security_departments, 500),
'categories': np.random.choice(categories, 500),
'area': np.random.choice(area, 500),
}

# Create the DataFrame
df = pd.DataFrame(data)

# Map security departments to security men
department_mapping = {
'Faisal Alhemeli': 'Security Department 1',
'Abdulwahid Alhemod': 'Security Department 1',
}
df['Security Department'] = df['Security Man'].map(department_mapping).fillna('Security Department 2')

# Chart 1: Line chart for 2023 and 2024 traffic violations based on week numbers
df['Year'] = np.random.choice([2023, 2024], df.shape[0])
line_chart_data = df.groupby(['Year', 'Week']).size().reset_index(name='Count')

# Chart 2: Bar chart for total violations on each department
bar_chart_total_dept = df.groupby('Department').size().reset_index(name='Total Violations')

# Chart 3: Bar chart for each department's total violations
bar_chart_dept_total = df.groupby(['Department', 'Violation Type']).size().reset_index(name='Count')

# Chart 4: Bar chart for status of traffic violations
bar_chart_status = df.groupby('Status').size().reset_index(name='Count')

# Chart 5: Bar chart for each department's violations weekly
bar_chart_dept_weekly = df.groupby(['Department', 'Week']).size().reset_index(name='Count')

# Chart 6: Pie chart for violation categories
pie_chart_categories = df.groupby('categories').size().reset_index(name='Count')

# Chart 7: Bar chart for area of traffic violations
bar_chart_area = df.groupby('area').size().reset_index(name='Count')

# Chart 8: Pie chart for responsible of traffic violations
pie_chart_responsible = df.groupby('Source').size().reset_index(name='Count')

# Chart 9: Bar chart for type of violation
bar_chart_violation_type = df.groupby('Violation Type').size().reset_index(name='Count')

# Chart 10: Bar chart for source of traffic violation
bar_chart_source = df.groupby('Source').size().reset_index(name='Count')

# Chart 11: Bar chart for security men initiating traffic violations
bar_chart_security_men = df.groupby('Security Man').size().reset_index(name='Count')

# Chart 12: Bar chart for security man departments
bar_chart_security_departments = df.groupby(['Security Man', 'Security Department']).size().reset_index(name='Count')

# Now you can use Plotly to create the charts
# For example, to create a line chart:
# fig1 = px.line(line_chart_data, x='Week', y='Count', color='Year', title='Traffic Violations by Week')
# fig2 = px.bar(bar_chart_total_dept, x='Department', y='Total Violations', color='Year', title='Traffic Violations by Week')
# fig3 = px.bar(bar_chart_dept_total, x='Department', y='Count', color='Violation Type', title='Traffic Violations by Week')
# fig3.update_layout(barmode='group'),
# fig4 = px.bar(bar_chart_status, x='Status', y='Count', title='Traffic Violations by Week')
# fig5 = px.bar(bar_chart_dept_weekly, x='Week', y='Count', color='Department', title='Traffic Violations by Week')
# fig6 = px.pie(pie_chart_categories, values='Count', names='categories', title='Traffic Violations by Week')
# fig7 = px.bar(bar_chart_area, x='area', y='Count', color='area', title='Traffic Violations by Week')
# fig8 = px.pie(pie_chart_responsible, values='Count', names='Source', title='Traffic Violations by Week')
# fig9 = px.bar(bar_chart_violation_type, x='Violation Type', y='Count', color='Violation Type', title='Traffic Violations by Week')
# fig10 = px.bar(bar_chart_source, x='Source', y='Count', color='Source', title='Traffic Violations by Week')
fig11 = px.bar(bar_chart_security_men, x='Security Man', y='Count', color='Security Man', title='Traffic Violations by Week')
fig12 = px.line(line_chart_data, x='Week', y='Count', color='Year', title='Traffic Violations by Week')

# Similarly, you can create other charts using the respective dataframes
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.