Skip to content

Instantly share code, notes, and snippets.

@pjastr

pjastr/HAA.md Secret

Last active April 25, 2019 11:57
Show Gist options
  • Save pjastr/5002cd113ec1082ca8e8a5fc79212e9c to your computer and use it in GitHub Desktop.
Save pjastr/5002cd113ec1082ca8e8a5fc79212e9c to your computer and use it in GitHub Desktop.

Koncepcja "tidy data":

  • jedna obserwacja (jednostka statystyczna) = jeden wiersz w tabeli/macierzy/ramce danych
  • wartosci danej cechy znajduja sie w kolumnach
  • jeden typ/rodzaj obserwacji w jednej tabeli/macierzy/ramce danych
import numpy as np

data = np.genfromtxt('jajka1.csv', delimiter=";", dtype='|U16')

data2 = np.array([[s.replace(',', '.') for s in line] for line in data])

shape = data2.shape
sampleNumber = shape[0] * shape[1]
lokalizacja = np.empty([sampleNumber, 2], dtype='|U16')
cena = np.zeros(sampleNumber, dtype=float)

n = 0
for i in range(1, shape[0]):
    for j in range(1, shape[1]):
        if data2[i][j] != "":
            lokalizacja[n][0] = data2[i][0]
            lokalizacja[n][1] = data2[0][j]
            cena[n] = float(data2[i][j])
            n += 1

lokalizacja2 = lokalizacja[:-sampleNumber + n]
cena2 = cena[:-sampleNumber + n]

srednia = np.mean(cena2)

minCena = np.min(cena2)
lokMin = lokalizacja2[cena2 == minCena]
maxCena = np.max(cena2)
lokMax = lokalizacja2[cena2 == maxCena]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment