{"id":3866,"date":"2024-03-27T11:19:21","date_gmt":"2024-03-27T11:19:21","guid":{"rendered":"http:\/\/van-maanen.com\/?p=3866"},"modified":"2024-03-27T11:19:21","modified_gmt":"2024-03-27T11:19:21","slug":"descriptive-statistics-in-python","status":"publish","type":"post","link":"http:\/\/archief.van-maanen.com\/?p=3866","title":{"rendered":"Descriptive statistics in python"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Below, a programme  is provided that shows the point cloud with a line that is the best fit to it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import pandas as pd\nimport sqlalchemy as sa\nimport matplotlib.pyplot as plt\nimport numpy as np\n\ntable_name = 'MIGRATED_DIVORCE_SETTLEMENT__C'\n\nconnection_string = \"DRIVER={ODBC Driver 17 for SQL Server};SERVER=DESKTOP-8J58OIP\\MSSQLSERVER_19;DATABASE=Speel;UID=sa;PWD=**\"\nconnection_url = sa.engine.URL.create(\"mssql+pyodbc\", query={\"odbc_connect\": connection_string})\nengine = sa.engine.create_engine(connection_url)\nwith engine.begin() as conn:\n    df = pd.read_sql_query(sa.text(\"SELECT * FROM Rapportage.\" + table_name), conn)\n\nonderzoek = df[['Person_ID_1__c','Person_ID_2__c']].apply(pd.to_numeric).dropna()\nprint(onderzoek.info())\nprint(onderzoek.head())\n\ny = onderzoek['Person_ID_1__c']\nx = onderzoek['Person_ID_2__c']\n\n#add points to plot\nplt.scatter(onderzoek['Person_ID_2__c'], onderzoek['Person_ID_1__c'], color='purple')\na, b = np.polyfit(onderzoek['Person_ID_2__c'], onderzoek['Person_ID_1__c'], 1)\nplt.plot(onderzoek['Person_ID_2__c'], a*onderzoek['Person_ID_2__c']+b)\nplt.text(1, 90, 'y = ' + '{:.3f}'.format(b) + ' + {:.3f}'.format(a) + 'x', size=12)\n\nprint('**********programma beindigd****')<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"http:\/\/van-maanen.com\/wp-content\/uploads\/2024\/03\/Screenshot-2024-03-27-121708.png\" alt=\"\" class=\"wp-image-3867\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Below, a programme is provided that shows the point cloud with a line that is the best fit to it. import pandas as pd import sqlalchemy as sa import matplotlib.pyplot as plt import numpy as np table_name = &#8216;MIGRATED_DIVORCE_SETTLEMENT__C&#8217; connection_string = &#8220;DRIVER={ODBC Driver 17 for SQL Server};SERVER=DESKTOP-8J58OIP\\MSSQLSERVER_19;DATABASE=Speel;UID=sa;PWD=**&#8221; connection_url = sa.engine.URL.create(&#8220;mssql+pyodbc&#8221;, query={&#8220;odbc_connect&#8221;: connection_string}) engine = sa.engine.create_engine(connection_url) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-3866","post","type-post","status-publish","format-standard","hentry","category-niet-gecategoriseerd"],"_links":{"self":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts\/3866","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3866"}],"version-history":[{"count":0,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=\/wp\/v2\/posts\/3866\/revisions"}],"wp:attachment":[{"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3866"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3866"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/archief.van-maanen.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}