From 928056aa2e7f3a443fc4972e196d6c6487a1c46f Mon Sep 17 00:00:00 2001 From: s327689 Date: Sun, 3 Jun 2018 11:07:28 +0200 Subject: [PATCH] tasks --- labs06/tasks.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/labs06/tasks.py b/labs06/tasks.py index 9c1763e..5fd2b6e 100755 --- a/labs06/tasks.py +++ b/labs06/tasks.py @@ -9,7 +9,8 @@ import pandas as pd """ 2. Wczytaj zbiór danych `311.csv` do zniennej data. """ -data = pd.read_csv() + +data = pd.read_csv("labs06/311.csv") """ 3. Wyświetl 5 pierwszych wierszy z data. @@ -31,27 +32,33 @@ print(shape) """ 6. Wyświetl kolumnę 'City' z powyższego zbioru danych. """ - +print(data['City']) """ 7. Wyświetl jakie wartoścu przyjmuje kolumna 'City'. """ +data.City.unique() """ 8. Wyświetl tabelę rozstawną kolumny City. """ - +t = data.City.value_counts() +print(t) """ 9. Wyświetl tylko pierwsze 4 wiersze z wcześniejszego polecenia. """ - +t.head(4) """ 10. Wyświetl, w ilu przypadkach kolumna City zawiera NaN. """ - +p = pd.DataFrame(data['City'].isnull()) +t = p[p['City'] == True] +shape = t.shape +rows = shape[0] +print(rows) """ 11. Wyświetl data.info() @@ -67,17 +74,22 @@ print(data[['Borough', 'Agency']].tail()) NYPD. Zlicz ile jest takich przykładów. """ p = data[data['Agency'] == 'NYPD'] -data.Agency.value_counts() +p.Agency.value_counts() """ 14. Wyświetl wartość minimalną i maksymalną z kolumny Longitude. """ +data['Longitude'].max() +data['Longitude'].min() """ 15. Dodaj kolumne diff, która powstanie przez sumowanie kolumn Longitude i Latitude. """ data['diff'] = data['Longitude'] + data['Latitude'] + """ 16. Wyświetl tablę rozstawną dla kolumny 'Descriptor', dla której Agency jest równe NYPD. """ +p = data[data['Agency'] == 'NYPD'] +p.City.value_counts() \ No newline at end of file