Skip to content
Snippets Groups Projects
Commit ae948039 authored by Johannes Huschens's avatar Johannes Huschens
Browse files

Delete Datenanalyse_data-1.ipynb

parent 5f79d96f
Branches
No related tags found
No related merge requests found
%% Cell type:code id:39b5f535 tags:
``` python
import pandas as pd
```
%% Cell type:code id:e84390b6 tags:
``` python
from matplotlib import pyplot as plt
```
%% Cell type:code id:3baee1a0-92cc-4d06-8bf6-76d38528079c tags:
``` python
sample_data = pd.read_csv('urliste_data-1.csv', encoding ="ISO-8859-1" , parse_dates= [0], dayfirst=True)
```
%% Cell type:code id:3b862dc8-5ef1-4f52-a0e3-5fecb0402fe0 tags:
``` python
sample_data
```
%% Output
Jahr Bevölkerungsstand
0 1950-12-31 50958125
1 1951-12-31 51434777
2 1952-12-31 51863761
3 1953-12-31 52453806
4 1954-12-31 52943295
.. ... ...
67 2017-12-31 82792351
68 2018-12-31 83019213
69 2019-12-31 83166711
70 2020-12-31 83155031
71 2021-12-31 83237124
[72 rows x 2 columns]
%% Cell type:code id:948b6220-27a4-40ce-95e8-46d2512a7fcb tags:
``` python
#R1.6 excel-datei
sample_data.to_excel("excel_data-1.xlsx", sheet_name = "Sheet1")
```
%% Cell type:code id:eda9688e-eb77-48c9-9a25-9c5a978fafc3 tags:
``` python
jahre = pd.to_numeric(sample_data.Jahr)
```
%% Cell type:code id:130fcbbc-9808-4558-8104-58cabb24373c tags:
``` python
#R1.7 arith. Mittel Bevölkerungsstand
mean_bevoelkerung = sample_data.Bevölkerungsstand.mean()
print(mean_bevoelkerung)
#arith. Mittel Jahr
mean_date=sample_data.Jahr.mean()
print(mean_date)
```
%% Output
69025182.1388889
1986-07-01 12:00:00
%% Cell type:code id:286e6fa7-b3f1-4ad7-9d80-5c764517489f tags:
``` python
#R1.7 median Bevölkerungsstand
median_bevoelkerung= sample_data.Bevölkerungsstand.median()
print(median_bevoelkerung)
#median Jahr
median_date=sample_data.Jahr.median()
print(median_date)
```
%% Output
61762240.5
1986-07-01 12:00:00
%% Cell type:code id:d6443f4e-176e-40a4-997c-5f9f31900296 tags:
``` python
#R1.7 modus Bevölkerungsstand und Jahr
mode_bevoelkerung=sample_data.Bevölkerungsstand.mode()
print(mode_bevoelkerung)
mode_date=sample_data.Jahr.mode()
print(mode_date)
```
%% Output
0 50958125
1 51434777
2 51863761
3 52453806
4 52943295
...
67 82792351
68 83019213
69 83155031
70 83166711
71 83237124
Name: Bevölkerungsstand, Length: 72, dtype: int64
0 1950-12-31
1 1951-12-31
2 1952-12-31
3 1953-12-31
4 1954-12-31
...
67 2017-12-31
68 2018-12-31
69 2019-12-31
70 2020-12-31
71 2021-12-31
Name: Jahr, Length: 72, dtype: datetime64[ns]
%% Cell type:code id:259eb698-7074-4b50-8789-80c58cc6f156 tags:
``` python
#R1.8 Spannweite Bevölkerungsstand und Jahr
spannweite_bevoelkerung=sample_data.Bevölkerungsstand.max()-sample_data.Bevölkerungsstand.min()
print(spannweite_bevoelkerung)
spannweite_date=sample_data.Jahr.max()-sample_data.Jahr.min()
print(spannweite_date)
```
%% Output
32278999
25933 days 00:00:00
%% Cell type:code id:06c7ad43-6425-41b4-be9a-f7db4ac4ef03 tags:
``` python
#R1.9 mittlere Abweichung vom Median
n = len(sample_data)
value = 0
for i in range(n):
value += abs(sample_data.Bevölkerungsstand.iloc[i] - sample_data.Bevölkerungsstand.median())
MA_median_population = value/n
print(MA_median_population)
#für Jahr nicht berechenbar, da es sich um eine Intervallskala handelt
```
%% Output
10703382.222222222
%% Cell type:code id:e9a5daba-41d3-4323-97e9-09d87370c2b0 tags:
``` python
#R1.10 Varianz Bevölkerungsstand
sample_data.Bevölkerungsstand.var()
#für Jahr nicht berechenbar, da es sich um eine Intervallskala handelt
```
%% Output
142802788477530.62
%% Cell type:code id:9edcc4a6-c295-4f61-ae25-9bee9ac5fcf5 tags:
``` python
#R1.11 Variationskoeffizient Bevölkerungsstand
sample_data.Bevölkerungsstand.std()/sample_data.Bevölkerungsstand.mean()
#für Jahr nicht berechenbar, da es sich um eine Intervallskala handelt
```
%% Output
0.1731253971360521
%% Cell type:code id:102eb010-bf06-48aa-8ae2-a5eb27d96f6d tags:
``` python
#R1.12 Box-Whisker-Plot Bevölkerungsstand
plt.boxplot(sample_data.Bevölkerungsstand / 10**6)
plt.title("Boxplot Bevölkerungsstand Deutschland")
plt.ylabel("Bevölkerung in Millionen")
plt.savefig('boxplot.png')
plt.show()
#Befehl funktioniert nicht für Variable "Jahr"
```
%% Output
%% Cell type:code id:70b57b19-f047-48bd-acde-7488415001c5 tags:
``` python
#R1.13 scatterplot Bevölkerungsstand/Jahr
plt.plot(sample_data.Jahr, sample_data.Bevölkerungsstand / 10**6, 'o')
plt.title("Bevölkerungsstand Deutschland")
plt.xlabel("Jahr")
plt.ylabel("Bevölkerung in Millionen")
plt.savefig('scatter.png')
plt.show()
```
%% Output
%% Cell type:code id:4044f40b-50f0-4922-873c-1407b1d36dfa tags:
``` python
#R1.15 unteres Quartil Bevölkerungsstand
sample_data.Bevölkerungsstand.quantile(0.25)
```
%% Output
60334393.25
%% Cell type:code id:92c35c04-1ed7-49e8-8fa8-674706f9d498 tags:
``` python
#R1.15 unteres Quartil Jahr
sample_data.Jahr.quantile(0.25)
```
%% Output
Timestamp('1968-09-30 12:00:00')
%% Cell type:code id:8cd41c01-1015-4774-8b8d-cc4c9cf634ea tags:
``` python
#R1.15 oberes Quartil Bevölkerungsstand
sample_data.Bevölkerungsstand.quantile(0.75)
```
%% Output
82018374.25
%% Cell type:code id:851a4c4b-a4ac-45ca-bfb4-e7952a34f82b tags:
``` python
#R1.15 oberes Quartil Jahr
sample_data.Jahr.quantile(0.75)
```
%% Output
Timestamp('2004-03-31 12:00:00')
%% Cell type:code id:7e82a47c-32b6-4797-805a-0b6838f36988 tags:
``` python
#R1.15 "nulltes" Quartil Bevölkerungsstand
sample_data.Bevölkerungsstand.quantile(0)
```
%% Output
50958125.0
%% Cell type:code id:cde558cf-553b-4325-ba99-69e7b1b44859 tags:
``` python
#R1.15 "nulltes" Quartil Jahr
sample_data.Jahr.quantile(0)
```
%% Output
Timestamp('1950-12-31 00:00:00')
%% Cell type:code id:72a78de4-2148-4425-8976-38140ad28f91 tags:
``` python
#R1.15 unteres Dezil Bevölkerungsstand
sample_data.Bevölkerungsstand.quantile(0.1)
```
%% Output
54129844.4
%% Cell type:code id:8d362838-adc5-46b8-af4c-37ec903898f6 tags:
``` python
#R1.15 unteres Dezil Jahr
sample_data.Jahr.quantile(0.1)
```
%% Output
Timestamp('1958-02-05 12:00:00')
%% Cell type:code id:20398136-ecfc-4ae6-8c35-25a73684c95f tags:
``` python
#R1.15 Dezile Bevölkerungsstand
sample_data.Bevölkerungsstand.quantile(0.2)
```
%% Output
58729279.0
%% Cell type:code id:dcae6434-3e23-4898-999e-dcfa194f30ca tags:
``` python
#R1.15 Dezile Jahr
sample_data.Jahr.quantile(0.2)
```
%% Output
Timestamp('1965-03-14 00:00:00.000000032')
%% Cell type:code id:63014e96-7768-4bf1-b2d8-c68f7b9dfa86 tags:
``` python
#R1.15 Dezile Bevölkerungsstand
sample_data.Bevölkerungsstand.quantile(0.3)
```
%% Output
61076617.5
%% Cell type:code id:ba3384da-cb4d-4e10-a14f-2c8d5266dc18 tags:
``` python
#R1.15 Dezile Jahr
sample_data.Jahr.quantile(0.3)
```
%% Output
Timestamp('1972-04-18 19:12:00.000000016')
%% Cell type:code id:6ab49754-4743-4c63-807f-44bcdc05b514 tags:
``` python
#R1.15 Dezile Bevölkerungsstand
sample_data.Bevölkerungsstand.quantile(0.4)
```
%% Output
61440403.6
%% Cell type:code id:5d198d66-38b2-4d14-8b8b-1fa574067315 tags:
``` python
#R1.15 Dezile Jahr
sample_data.Jahr.quantile(0.4)
```
%% Output
Timestamp('1979-05-26 00:00:00.000000064')
%% Cell type:code id:8c25ac94-6131-4681-be76-766e84e4cd23 tags:
``` python
#R1.15 Dezile Bevölkerungsstand
sample_data.Bevölkerungsstand.quantile(0.6)
```
%% Output
80445407.6
%% Cell type:code id:e1abe102-777c-45c5-aa9e-722b96e71694 tags:
``` python
#R1.15 Dezile Jahr
sample_data.Jahr.quantile(0.6)
```
%% Output
Timestamp('1993-08-07 00:00:00')
%% Cell type:code id:9847ba5a-a342-455e-93e6-7024260399f7 tags:
``` python
#R1.15 Dezile Bevölkerungsstand
sample_data.Bevölkerungsstand.quantile(0.7)
```
%% Output
81787060.5
%% Cell type:code id:207b0cfd-e605-4b89-a021-430e6760f5d1 tags:
``` python
#R1.15 Dezile Jahr
sample_data.Jahr.quantile(0.7)
```
%% Output
Timestamp('2000-09-12 04:47:59.999999872')
%% Cell type:code id:12fff45d-0fec-43d6-b900-ef1f1ffc7bde tags:
``` python
#R1.15 Dezile Bevölkerungsstand
sample_data.Bevölkerungsstand.quantile(0.8)
```
%% Output
82173242.2
%% Cell type:code id:18383f84-7889-4259-8b19-1b0a63395b74 tags:
``` python
#R1.15 Dezile Jahr
sample_data.Jahr.quantile(0.8)
```
%% Output
Timestamp('2007-10-19 00:00:00.000000256')
%% Cell type:code id:d4370370-9a17-4e5c-a9d7-fa80c2acd64a tags:
``` python
#R1.15 oberes Dezil Bevölkerungsstand
sample_data.Bevölkerungsstand.quantile(0.9)
```
%% Output
82519572.6
%% Cell type:code id:d3c181cf-dff6-478f-9aa8-f8057d0fb34d tags:
``` python
#R1.15 oberes Dezil Jahr
sample_data.Jahr.quantile(0.9)
```
%% Output
Timestamp('2014-11-24 12:00:00')
%% Cell type:code id:8aac9b3b-c438-4ad6-b7ea-8961d1caa8a2 tags:
``` python
#R1.15 oberstes Quartil Bevölkerungsstand
sample_data.Bevölkerungsstand.quantile(1)
```
%% Output
83237124.0
%% Cell type:code id:ada1b24a-0b40-41c3-bb91-58f9255b0141 tags:
``` python
#R1.15 oberstes Quartil Jahr
sample_data.Jahr.quantile(1)
```
%% Output
Timestamp('2021-12-31 00:00:00')
%% Cell type:code id:5c3e774c-e50b-4d1f-91c7-b515d3dce62d tags:
``` python
#R1.16 IQR Bevölkerungsstand
sample_data.Bevölkerungsstand.quantile(0.75) - sample_data.Bevölkerungsstand.quantile(0.25)
```
%% Output
21683981.0
%% Cell type:code id:837a0551-d3d4-4d00-90a0-c09122fc0ae3 tags:
``` python
#R1.16 IQR Jahr
sample_data.Jahr.quantile(0.75) - sample_data.Jahr.quantile(0.25)
```
%% Output
Timedelta('12966 days 00:00:00')
%% Cell type:code id:49f4295a-e440-441f-8ffd-a8b85da48637 tags:
``` python
#R1.17 Kovarianz nicht errechenbar, da sich die Variable "Jahr" auf einer Intervallskala bewegt.
```
%% Cell type:code id:613bd31f-4250-43bc-b1fc-2b08fb4e1e12 tags:
``` python
#R1.18 Korrelationskoeffizient nicht errechenbar, da sich die Variable "Jahr" auf einer Intervallskala bewegt.
```
%% Cell type:code id:45e1aba9-aedd-4c98-919d-ba663935f016 tags:
``` python
#R1.19 Klassen, Histogramm
plt.hist(sample_data.Bevölkerungsstand/10**6, density = True, bins= [50, 55, 60, 65, 70, 75, 80, 85])
plt.title("Bevölkerungsstand Deutschland")
plt.xlabel("Bevölkerungsstände in Millionen")
plt.ylabel("relative Häufigkeit")
plt.savefig('hist.png')
```
%% Output
%% Cell type:code id:cea71fad-8e5e-4ccb-8640-3f1bf40633e8 tags:
``` python
#R1.20 Kontingenztabelle
```
%% Cell type:code id:07f4273c-8f20-4306-bf7a-d25127bafcf9 tags:
``` python
#R1.21 Rangkorrelationskoeffizient nach Spearman
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment