{"id":1866,"date":"2022-01-24T22:09:02","date_gmt":"2022-01-24T16:39:02","guid":{"rendered":"https:\/\/cbsepython.in\/?p=1866"},"modified":"2023-12-28T10:11:24","modified_gmt":"2023-12-28T04:41:24","slug":"covid-19-data-visualization-python-project-class-12","status":"publish","type":"post","link":"https:\/\/cbsepython.in\/covid-19-data-visualization-python-project-class-12\/","title":{"rendered":"COVID-19 Data Visualization Python Project Class 12"},"content":{"rendered":"<h2>COVID-19 Data Visualization Python Project Class 12<\/h2>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong># Python Project for Class 12 Informatics Practices (065), <\/strong>Python MySQL program containing bar graph, line chart, scatter chart<\/span><\/p>\n<p><span style=\"color: #000000;\"><strong>Note: If you found something wrong or unable to execute the program kindly mention in comment box provided below the article.<\/strong><\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">#cbsepython.in\r\nimport pandas as pd\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\n\r\ndef Fun():\r\n    print(\":)\")\r\n    print(\"#1. For checking the data.\")\r\n    print(\"#2. Reading complete file without index.\")\r\n    print(\"===================\")\r\n    print(\"Topic - Data Visualization\")\r\n    print(\" \")\r\n    print(\"#3. Line Chart\")\r\n    print(\"    Press 1 to print the data for Confirmed cases as per Districts.\")\r\n    print(\"    Press 2 to print the data for Recovered cases as per Districts.\")\r\n    print(\"    Press 3 to print the data for Death cases as per Districts.\")\r\n    print(\"    Press 4 to print the data for Active cases as per Districts.\")\r\n    print(\"    Press 5 to print All data.\")\r\n    print(\" \")\r\n    print(\"#4. Bar Graph\")\r\n    print(\"    Press 1 to print the data for Confirmed cases as per Districts.\")\r\n    print(\"    Press 2 to print the data for Recovered cases as per Districts.\")\r\n    print(\"    Press 3 to print the data for Death cases as per Districts.\")\r\n    print(\"    Press 4 to print the data for Active cases as per Districts.\")\r\n    print(\"    Press 5 to print the data in form of stack bar chart\")\r\n    print(\"    Press 6 to print the data in form of multi bar chart\")\r\n    print(\" \")\r\n    print(\"#5. Scatter Chart\")\r\n    print(\" \")\r\n    print(\"#6. For Exit\")\r\n    print(\"===============\")\r\n\r\n\r\ndef Read_CSV():\r\n    print(\"The Data\")\r\n    df=pd.read_csv('D:\\\\Covid_data_kerala.csv')\r\n    print(df)\r\n\r\ndef No_Index():\r\n    print(\"Reading the file without index\")\r\n    df=pd.read_csv('D:\\\\Covid_data_kerala.csv', index_col=0)\r\n    print(df)\r\n\r\n\r\n#FOR LINE CHART:)\r\n\r\ndef line_plot():\r\n    df=pd.read_csv('D:\\\\Covid_data_kerala.csv')\r\n    df['Districts'] = ['EKM','PTA','KTM','TSR','KKD','MPM','KLM','PKD','ALP','KNR','TVM','IDK','WYD','KGD']\r\n    District=df[\"Districts\"]\r\n    Confirmed=df[\"Confirmed\"]\r\n    Recovered=df[\"Recovered\"]\r\n    Deaths=df[\"Deaths\"]\r\n    Active=df[\"Active\"]\r\n    plt.xlabel(\"Districts\")\r\n\r\n    \r\n    YC = int(input(\"Enter the number representing your preferred line chart from the above choices: \"))\r\n    \r\n    if YC == 1:\r\n        plt.ylabel(\"Confirmed Cases\")\r\n        plt.title(\"Districts Wise Confirmed Cases\")\r\n        plt.plot(District, Confirmed, color='b')\r\n        plt.show()\r\n    elif YC == 2:\r\n        plt.ylabel(\"Recovered Cases\")\r\n        plt.title(\"Districts Wise Recovered Cases\")\r\n        plt.plot(District, Recovered, color='g')\r\n        plt.show()\r\n    elif YC == 3:\r\n        plt.ylabel(\"Death Cases\")\r\n        plt.title(\"Districts Wise Death Cases\")\r\n        plt.plot(District, Deaths, color='r')\r\n        plt.show()\r\n    elif YC == 4:\r\n        plt.ylabel(\"Active Cases\")\r\n        plt.title(\"Districts Wise Active Cases\")\r\n        plt.plot(District, Active, color='c')\r\n        plt.show()\r\n    elif YC == 5:\r\n        plt.ylabel(\"Number of cases\")\r\n        plt.plot(District, Confirmed, color='b', label = \"Districts Wise Confirmed Cases\")\r\n        plt.plot(District, Recovered, color='g', label = \"Districts Wise Recovered Cases\")\r\n        plt.plot(District, Deaths, color='r', label = \"Districts Wise Death Cases\")\r\n        plt.plot(District, Active, color='c', label = \"Districts Wise Active Cases\")\r\n        plt.legend()\r\n        plt.show()\r\n    else:\r\n        print(\"Enter valid input\")\r\n        \r\n\r\n#FOR BAR GRAPH:)\r\n\r\ndef bar_plot():\r\n    df = pd.read_csv('Covid_data_kerala.csv')\r\n    df['Districts'] = ['EKM','PTA','KTM','TSR','KKD','MPM','KLM','PKD','ALP','KNR','TVM','IDK','WYD','KGD']\r\n    District = df[\"Districts\"]\r\n    Confirmed = df[\"Confirmed\"]\r\n    Recovered = df[\"Recovered\"]\r\n    Deaths = df[\"Deaths\"]\r\n    Active = df[\"Active\"]\r\n    plt.xlabel(\"Districts\")\r\n\r\n\r\n    YC = int(input(\"Enter the number representing your preferred bar graph from the above choices:\"))\r\n    \r\n    if YC == 1:\r\n        plt.ylabel(\"Confirmed Cases\")\r\n        plt.title(\"Districts Wise Confirmed Cases\")\r\n        plt.bar(District, Confirmed, color='b', width = 0.5)\r\n        plt.show()\r\n    elif YC == 2:\r\n        plt.ylabel(\"Recovered Cases\")\r\n        plt.title(\"Districts Wise Recovered Cases\")\r\n        plt.bar(District, Recovered, color='g', width = 0.5)\r\n        plt.show()\r\n    elif YC == 3:\r\n        plt.ylabel(\"Death Cases\")\r\n        plt.title(\"Districts Wise Death Cases\")\r\n        plt.bar(District, Deaths, color='r', width = 0.5)\r\n        plt.show()\r\n    elif YC == 4:\r\n        plt.ylabel(\"Active Cases\")\r\n        plt.title(\"Districts Wise Active Cases\")\r\n        plt.bar(District, Active, color='c', width = 0.5)\r\n        plt.show()\r\n    elif YC == 5:\r\n        plt.bar(District, Confirmed, color='b', width = 0.5, label = \"Districts Wise Confirmed Cases\")\r\n        plt.bar(District, Recovered, color='g', width = 0.5, label = \"Districts Wise Recovered Cases\")\r\n        plt.bar(District, Deaths, color='r', width = 0.5, label = \"Districts Wise Death Cases\")\r\n        plt.bar(District, Active, color='c',width = 0.5, label = \"Districts Wise Active Cases\")\r\n        plt.legend()\r\n        plt.show()\r\n    elif YC == 6:\r\n        D=np.arange(len(District))\r\n        width=0.25\r\n        plt.bar(D,Confirmed, width, color='b', label = \"Districts Wise Confirmed Cases\")\r\n        plt.bar(D+0.25, Recovered, width, color='g', label = \"Districts Wise Recovered Cases\")\r\n        plt.bar(D+0.50, Deaths, width, color='r', label = \"Districts Wise Death Cases\")\r\n        plt.bar(D+0.75, Active ,width, color='c', label = \"Districts Wise Active Cases\")\r\n        plt.legend()\r\n        plt.show()\r\n    else:\r\n        print(\"Enter valid input\")\r\n        \r\ndef scatter_chart():\r\n    df=pd.read_csv('Covid_data_kerala.csv')\r\n    df['Districts'] = ['EKM','PTA','KTM','TSR','KKD','MPM','KLM','PKD','ALP','KNR','TVM','IDK','WYD','KGD']\r\n    District = df[\"Districts\"]\r\n    Confirmed = df[\"Confirmed\"]\r\n    Recovered = df[\"Recovered\"]\r\n    Deaths = df[\"Deaths\"]\r\n    Active = df[\"Active\"]\r\n    \r\n    SC=plt.gca()\r\n    SC=plt.scatter(District, Confirmed, color=\"b\", label=\"Districts Wise Confirmed Cases\")\r\n    SC=plt.scatter(District, Recovered, color=\"g\", label=\"Districts Wise Recovered Cases\")\r\n    SC=plt.scatter(District, Deaths, color=\"r\", label=\"Districts Wise Death Cases\")\r\n    SC=plt.scatter(District, Active, color=\"c\", label=\"Districts Wise Active Cases\")\r\n    \r\n    plt.xlabel(\"District\")\r\n    plt.title(\"Complete Scatter Chart\")\r\n    plt.legend()\r\n    plt.show()\r\n    \r\nFun()\r\nYC = int(input(\"Enter Your Choice: \"))\r\n\r\nwhile YC == 1 or 2 or 3 or 4 or 5 or 6:\r\n\r\n    if YC == 1:\r\n        Read_CSV()\r\n        break\r\n    elif YC == 2:\r\n        No_Index()\r\n        break\r\n    elif YC == 3:\r\n        line_plot()\r\n        break\r\n    elif YC == 4:\r\n        bar_plot()\r\n        break\r\n    elif YC == 5:\r\n        scatter_chart()\r\n        break\r\n    elif YC == 6:\r\n        print(\"Thank You for using...\")\r\n        break\r\n    else:\r\n        print(\"Enter valid input\")\r\n        break\r\n<\/pre>\n<p>&nbsp;<\/p>\n<h2><span style=\"color: #000000;\">Sample CSV file for the above code:\u00a0<\/span><\/h2>\n<p><a href=\"https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/Covid_data_kerala.csv\">Covid_data_kerala<\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong><span style=\"color: #000000;\">Output:<\/span><\/strong><\/p>\n<pre>=== RESTART: C:\\Users\\ATC\\AppData\\Local\\Programs\\Python\\Python38-32\\COVID.PY \r\n#1. For checking the data.\r\n#2. Reading complete file without index.\r\n===================\r\nTopic - Data Visualization\r\n\r\n#3. Line Chart\r\nPress 1 to print the data for Confirmed cases as per Districts.\r\nPress 2 to print the data for Recovered cases as per Districts.\r\nPress 3 to print the data for Death cases as per Districts.\r\nPress 4 to print the data for Active cases as per Districts.\r\nPress 5 to print All data.\r\n\r\n#4. Bar Graph\r\nPress 1 to print the data for Confirmed cases as per Districts.\r\nPress 2 to print the data for Recovered cases as per Districts.\r\nPress 3 to print the data for Death cases as per Districts.\r\nPress 4 to print the data for Active cases as per Districts.\r\nPress 5 to print the data in form of stack bar chart\r\nPress 6 to print the data in form of multi bar chart\r\n\r\n#5. Scatter Chart\r\n\r\n#6. For Exit\r\n===============\r\nEnter Your Choice: \r\n\r\n\r\n\r\n<\/pre>\n<h3>Screenshot :<\/h3>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-1867 size-full\" src=\"https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/covid19_1.jpg\" alt=\"covid-19 python project\" width=\"904\" height=\"687\" title=\"\" srcset=\"https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/covid19_1.jpg 904w, https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/covid19_1-300x228.jpg 300w, https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/covid19_1-768x584.jpg 768w, https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/covid19_1-395x300.jpg 395w\" sizes=\"(max-width: 904px) 100vw, 904px\" \/> <img decoding=\"async\" class=\"alignnone wp-image-1868 size-full\" src=\"https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/covid19_2.jpg\" alt=\"\" width=\"729\" height=\"394\" title=\"\" srcset=\"https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/covid19_2.jpg 729w, https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/covid19_2-300x162.jpg 300w, https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/covid19_2-400x216.jpg 400w\" sizes=\"(max-width: 729px) 100vw, 729px\" \/> <img decoding=\"async\" class=\"alignnone wp-image-1869 size-full\" src=\"https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/covid19_3.jpg\" alt=\"\" width=\"653\" height=\"549\" title=\"\" srcset=\"https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/covid19_3.jpg 653w, https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/covid19_3-300x252.jpg 300w, https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/covid19_3-357x300.jpg 357w\" sizes=\"(max-width: 653px) 100vw, 653px\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1870 size-full\" src=\"https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/covid19_4.jpg\" alt=\"\" width=\"653\" height=\"552\" title=\"\" srcset=\"https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/covid19_4.jpg 653w, https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/covid19_4-300x254.jpg 300w, https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/covid19_4-355x300.jpg 355w\" sizes=\"(max-width: 653px) 100vw, 653px\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1871 size-full\" src=\"https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/covid19_5.jpg\" alt=\"\" width=\"648\" height=\"547\" title=\"\" srcset=\"https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/covid19_5.jpg 648w, https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/covid19_5-300x253.jpg 300w, https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/covid19_5-355x300.jpg 355w\" sizes=\"(max-width: 648px) 100vw, 648px\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1872 size-full\" src=\"https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/Covid19_6.jpg\" alt=\"\" width=\"649\" height=\"543\" title=\"\" srcset=\"https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/Covid19_6.jpg 649w, https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/Covid19_6-300x251.jpg 300w, https:\/\/cbsepython.in\/wp-content\/uploads\/2022\/01\/Covid19_6-359x300.jpg 359w\" sizes=\"(max-width: 649px) 100vw, 649px\" \/><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>COVID-19 Data Visualization Python Project Class 12 &nbsp; # Python Project for Class 12 Informatics Practices (065), Python MySQL program containing bar graph, line chart, scatter chart Note: If you found something wrong or unable to execute the program kindly mention in comment box provided below the article. &nbsp; &nbsp; #cbsepython.in import pandas as pd [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,43],"tags":[],"class_list":["post-1866","post","type-post","status-publish","format-standard","hentry","category-cbse-sample-papers-class-12","category-python-projects"],"_links":{"self":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/posts\/1866","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/comments?post=1866"}],"version-history":[{"count":0,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/posts\/1866\/revisions"}],"wp:attachment":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/media?parent=1866"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/categories?post=1866"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/tags?post=1866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}