Jupyter Notebook Nedir? Veri Analistleri İçin Kullanım Rehberi

Kod, açıklama ve grafik aynı belgede. Jupyter Notebook'u kurmaktan hücre sırasının neden önemli olduğuna, bir analizi baştan sona yürütmekten paylaşmadan önce yapılacak son kontrole kadar pratik bir rehber.

  • Araçlar

Jupyter Notebook nedir?

Jupyter Notebook, kod hücrelerini, açıklayıcı metni ve çalıştırma çıktılarını tek bir etkileşimli belgede toplayan bir çalışma ortamıdır. Analisti ilgilendiren kısım şu: kodu küçük parçalar hâlinde çalıştırıp ara sonucu hemen görebilir, o sonucun ne anlama geldiğini aynı dosyada yazabilirsiniz. Belge .ipynb uzantısıyla saklanır ve içinde kodun yanı sıra üretilen tablolar, grafikler ve metin de bulunur.

Arayüz, kodu asıl çalıştıran kernel ile konuşur. Python için bu kernel IPython'dur. Bir hücreyi çalıştırdığınızda kod kernel'e gider, sonuç hücrenin altına döner. Kernel arka planda bir oturum tutar; yani bir hücrede tanımladığınız değişken, sonraki hücrelerde de yaşamaya devam eder.

Nerede parlar: Keşifsel analiz, bir yöntemi adım adım anlatmak, hızlı deney yapmak. Nerede zorlanır: Üretimde her gün çalışacak bir iş akışı. O noktada tekrar eden mantığı .py modüllerine taşıyıp notebook'u yalnızca keşif ve sunum için kullanmak bakımı kolaylaştırır.

Kurulum ve ilk çalıştırma

Her proje için ayrı bir sanal ortam kurmak, paket sürümlerinin birbirine karışmasını engeller. Analiz projelerinde bu, aylar sonra "neden artık çalışmıyor?" sorusunu büyük ölçüde ortadan kaldırır.

Ortam kurulumu — terminal
# proje klasöründe sanal ortam
python -m venv .venv

# Windows PowerShell
.venv\Scripts\Activate.ps1
# macOS / Linux
source .venv/bin/activate

python -m pip install notebook pandas matplotlib

Ortam etkinken sunucuyu proje klasöründe başlatın. Tarayıcıda yerel bir arayüz açılır; oradan yeni bir Python notebook oluşturabilirsiniz.

Sunucuyu başlatma
jupyter notebook
En sık yaşanan ilk sorun: paketleri kurduğunuz ortam ile notebook'un kullandığı kernel farklıdır. ModuleNotFoundError gördüğünüzde paketi tekrar kurmadan önce hücrede import sys; print(sys.executable) yazıp hangi Python'un çalıştığına bakın.

Hücre yapısı ve çalıştırma

Notebook üç tür hücre tanır. Code hücresi seçili kernel'de kod çalıştırır. Markdown hücresi başlık, liste, bağlantı, kalın yazı ve matematik ifadesi üretir. Raw hücre ise işlenmeden kalır; bazı dışa aktarma akışlarında ham içerik taşımak için kullanılır.

İşlemKısayolSonuç
Çalıştır ve ilerleShift + EnterHücreyi çalıştırır, sonrakine geçer
Çalıştır ve kalCtrl + EnterHücreyi çalıştırır, seçim aynı hücrede kalır
Çalıştır ve alta ekleAlt + EnterÇalıştırır ve altına boş hücre açar
Kernel'i sıfırlaMenü: Kernel → RestartBellekteki tüm değişkenler silinir

Burada dikkat edilmesi gereken bir ayrıntı var: hücrelerin görünür sırası ile çalıştırıldıkları sıra aynı olmak zorunda değildir. Hücrenin solundaki köşeli parantez içindeki sayı, o hücrenin kaçıncı sırada çalıştırıldığını gösterir. Yukarıdan aşağı 1, 2, 3 gitmiyorsa, belge başka birinin bilgisayarında aynı sonucu vermeyebilir.

Bir analizi bitirdiğinizde son işiniz şu olsun: Kernel → Restart & Run All. Hata almadan baştan sona çalışmıyorsa, notebook henüz paylaşılmaya hazır değildir.

Markdown ile analizi anlatın

Notebook'u komut listesinden rapora dönüştüren şey Markdown hücreleridir. Pratik bir düzen: koddan önce ne yapacağınızı ve hangi varsayımla yaptığınızı, koddan sonra çıkan sonucun ne anlama geldiğini yazın. Üç satırlık bir açıklama, altı ay sonra kendinize yazdığınız en değerli nottur.

Markdown hücresi
# Aylık satış analizi

Sipariş kayıtlarından aylık ciro eğilimini çıkarıyoruz.

## Sorular
- Ciro aylara göre nasıl değişiyor?
- Hacmi en yüksek ürünler hangileri?

## Tanımlar
Ciro = adet × birim fiyat. İade satırları hariç tutuldu.

Başlıklar aynı zamanda gezinme aracıdır: uzun bir notebook'ta ## ile ayrılmış bölümler, içindekiler panelinde listelenir ve belgede dolaşmayı kolaylaştırır.

Bir analiz akışı baştan sona

Tipik akış dört adımdır: veriyi yükle, kaliteyi kontrol et, özeti çıkar, soruya uygun grafiği üret. Aşağıdaki örnek CSV sipariş kayıtlarından aylık ciroyu hesaplıyor.

Veriyi yükle ve kontrol et — Python
import pandas as pd

df = pd.read_csv("data/siparisler.csv", parse_dates=["tarih"])

display(df.head())
print(df.shape)
display(df.dtypes)
display(df.isna().sum())

Bu dört satır, analizin geri kalanını kurtaran adımdır. shape satır sayısını, dtypes tarihin gerçekten tarih olarak okunup okunmadığını, isna().sum() ise hangi sütunda ne kadar boşluk olduğunu söyler. Bir de kendinize şunu sorun: bir satır neyi temsil ediyor? Her satır bir sipariş kalemi ise, satır sayısı sipariş sayısı değildir.

Aylık özet ve grafik — pandas + matplotlib
import matplotlib.pyplot as plt

df["ciro"] = df["adet"] * df["birim_fiyat"]

aylik = (df.set_index("tarih")["ciro"]
           .resample("MS")
           .sum())

display(aylik.to_frame())

ax = aylik.plot(marker="o", figsize=(10, 4))
ax.set(title="Aylık ciro", xlabel="Ay", ylabel="Ciro (TL)")
plt.tight_layout()
plt.show()

Grafik, kodun hemen altında hücre çıktısı olarak görünür. İki küçük alışkanlık işi ciddiye alınır hâle getirir: eksenlere birim yazmak ve grafiğin altına bir Markdown hücresinde ne gördüğünüzü bir cümleyle söylemek.

Sessiz tuzak: resample("MS") hiç kaydı olmayan bir ay için boşluk bırakmaz, 0 döndürür. Grafikte sıfıra inen bir ay gördüğünüzde "o ay satış olmadı" ile "o ayın verisi gelmemiş" aynı görünür. Kayıt sayısını da ayrıca sayın.

Grafikler ve zengin çıktılar

Matplotlib görselleri doğrudan hücre çıktısı olarak gelir; plt.show() bunu açıkça tetikler. pandas da DataFrame'leri biçimli HTML tablosu olarak basar. Daha fazla etkileşim gerekiyorsa Plotly veya ipywidgets gibi kütüphaneler hücre içinde çalışan bileşenler üretebilir.

Çıktılar dosyanın içine kaydedilir. Bu, belgeyi kendi kendine yeten bir rapora dönüştürür ama iki yan etkisi vardır: dosya boyutu hızla büyür ve kaydedilmiş bir çıktı, kodu değiştirdikten sonra bile eski hâliyle orada durur. Büyük tabloları head() ile kısaltıp tam sonucu ayrı bir dosyaya yazmak iyi bir orta yoldur.

İyi notebook alışkanlıkları

1

Bir hücre, bir iş

Veri okuma, temizlik ve grafik ayrı hücrelerde dursun. Hata ayıklamak da, yeniden çalıştırmak da kolaylaşır.

2

Sırayı bozmayın

Yukarıdan aşağı çalışan bir belge hedefleyin. Hücreleri ileri geri çalıştırdığınız bir oturum tekrarlanabilir değildir.

3

Yolları tek yerde tutun

Dosya yollarını ve eşik değerlerini en üstteki bir hücrede değişken olarak tanımlayın.

4

Tekrarı modüle taşıyın

İki notebook'ta kopyaladığınız fonksiyon, artık src/ altında bir .py dosyasına aittir.

5

Bağımlılıkları yazın

requirements.txt veya eşdeğeri olmadan notebook başka bir makinede çalışmaz.

6

Hassas çıktıyı silin

Müşteri adı, e-posta, anahtar içeren çıktılar dosyaya gömülür. Paylaşmadan önce temizleyin.

Kaydetme, dışa aktarma, paylaşma

.ipynb dosyası aslında bir JSON belgesidir: hücreler, çıktılar ve kernel bilgisi içinde durur. Bu yüzden iki şeye dikkat edin. Birincisi, sürüm kontrolünde (Git) çıktı farkları okunmaz bir gürültü üretir; commit öncesi çıktıları temizlemek yaygın bir pratiktir. İkincisi, dosyayı birine gönderdiğinizde kodla birlikte bütün çıktıları da göndermiş olursunuz.

HTML'e dışa aktarma
jupyter nbconvert --to html analiz.ipynb

Üretilen HTML, dosyada kayıtlı olan çıktıları gösterir; hücreleri yeniden çalıştırmaz. Yani önce kernel'i sıfırlayıp baştan çalıştırmadan dışa aktarırsanız, rapora eski sonuçlar gider. Dönüştürmeden önce bir kez baştan çalıştırın, dışa aktardıktan sonra HTML'i de açıp göz gezdirin.

Sık karşılaşılan sorunlar

BelirtiOlası nedenNe yapmalı
ModuleNotFoundErrorKernel, paketi kurduğunuz ortam değilsys.executable ile kontrol edin, doğru kernel'i seçin
NameError: değişken tanımsızHücreler farklı sırada çalıştı veya kernel sıfırlandıRestart & Run All ile baştan çalıştırın
Çıktı kodla uyuşmuyorHücre değiştirildi ama yeniden çalıştırılmadıHücre numaralarına bakın, baştan çalıştırın
Dosya devasa büyüdüGömülü grafikler ve büyük tablo çıktılarıÇıktıları temizleyin, büyük sonuçları dosyaya yazın
Grafik görünmüyorFigür gösterilmeden kapandı veya backend sorunuplt.show() ekleyin, kernel'i yeniden başlatın

Sonuç

Jupyter Notebook'un gücü, düşünme sürecini görünür kılmasıdır: veriyi yoklarsınız, ne gördüğünüzü yazarsınız, bir sonraki adıma geçersiniz. Bu esneklik aynı zamanda en büyük riskidir — sırası bozulmuş, çıktıları eskimiş bir belge güven vermez.

Pratik kural basit: hücreleri küçük tutun, her bölümü bir cümleyle anlatın ve paylaşmadan önce kernel'i sıfırlayıp baştan çalıştırın. Bu üç alışkanlıkla notebook, yalnızca sizin çalıştığınız bir müsvedde olmaktan çıkıp başkasının takip edebileceği bir belgeye dönüşür.

What is Jupyter Notebook?

Jupyter Notebook is a working environment that brings code cells, explanatory text and execution output together in a single interactive document. The part that matters to an analyst is this: you can run code in small pieces, see the intermediate result immediately, and write down what it means in the same file. The document is stored with an .ipynb extension and holds not just the code but the tables, charts and text it produced.

The interface talks to a kernel, which is what actually runs the code. For Python that kernel is IPython. When you run a cell, the code goes to the kernel and the result comes back underneath it. The kernel keeps a session alive in the background, so a variable defined in one cell is still there in the next.

Where it shines: exploratory analysis, walking through a method step by step, quick experiments. Where it struggles: a workflow that has to run every day in production. At that point, moving repeated logic into .py modules and keeping the notebook for exploration and presentation makes maintenance much easier.

Installing and first run

Creating a separate virtual environment per project keeps package versions from colliding. In analysis projects this largely eliminates the "why doesn't this work any more?" question months later.

Environment setup — terminal
# virtual environment in the project folder
python -m venv .venv

# Windows PowerShell
.venv\Scripts\Activate.ps1
# macOS / Linux
source .venv/bin/activate

python -m pip install notebook pandas matplotlib

With the environment active, start the server inside the project folder. A local interface opens in the browser, and from there you can create a new Python notebook.

Starting the server
jupyter notebook
The most common first problem: the environment you installed packages into is not the kernel the notebook is using. When you see ModuleNotFoundError, before reinstalling anything, run import sys; print(sys.executable) in a cell and check which Python is actually running.

Cell types and execution

A notebook knows three kinds of cell. A Code cell runs code in the selected kernel. A Markdown cell produces headings, lists, links, bold text and mathematical expressions. A Raw cell is left unprocessed; it is used to carry verbatim content through certain export pipelines.

ActionShortcutResult
Run and advanceShift + EnterRuns the cell, moves to the next one
Run and stayCtrl + EnterRuns the cell, selection stays put
Run and insert belowAlt + EnterRuns it and opens an empty cell underneath
Reset the kernelMenu: Kernel → RestartClears every variable in memory

One detail deserves attention here: the visible order of cells and the order they were executed in do not have to match. The number in square brackets next to a cell shows its execution position. If it does not read 1, 2, 3 from top to bottom, the document may not produce the same result on somebody else's machine.

When you finish an analysis, make this your last step: Kernel → Restart & Run All. If it does not run top to bottom without errors, the notebook is not ready to be shared.

Narrate the analysis with Markdown

Markdown cells are what turn a notebook from a list of commands into a report. A practical layout: before the code, say what you are about to do and on what assumption; after the code, say what the result means. Three lines of explanation are the most valuable note you will ever write to your future self.

A Markdown cell
# Monthly sales analysis

We derive the monthly revenue trend from order records.

## Questions
- How does revenue change month to month?
- Which products carry the most volume?

## Definitions
Revenue = quantity × unit price. Return rows are excluded.

Headings double as navigation: in a long notebook, sections separated by ## are listed in the table-of-contents panel and make moving around far easier.

An analysis flow end to end

The typical flow has four steps: load the data, check its quality, summarise it, then draw the chart the question calls for. The example below computes monthly revenue from CSV order records.

Load and inspect — Python
import pandas as pd

df = pd.read_csv("data/orders.csv", parse_dates=["date"])

display(df.head())
print(df.shape)
display(df.dtypes)
display(df.isna().sum())

These four lines are the step that saves the rest of the analysis. shape gives the row count, dtypes tells you whether the date was really parsed as a date, and isna().sum() shows how much is missing in each column. Then ask yourself one more thing: what does a single row represent? If each row is an order line, the row count is not the order count.

Monthly summary and chart — pandas + matplotlib
import matplotlib.pyplot as plt

df["revenue"] = df["quantity"] * df["unit_price"]

monthly = (df.set_index("date")["revenue"]
             .resample("MS")
             .sum())

display(monthly.to_frame())

ax = monthly.plot(marker="o", figsize=(10, 4))
ax.set(title="Monthly revenue", xlabel="Month", ylabel="Revenue")
plt.tight_layout()
plt.show()

The chart appears as cell output right below the code. Two small habits make the work look serious: put units on the axes, and add a Markdown cell underneath saying in one sentence what you see.

A quiet trap: resample("MS") does not leave a gap for a month with no records — it returns 0. On the chart, "no sales that month" and "that month's data never arrived" look identical. Count the records separately as well.

Charts and rich output

Matplotlib figures appear directly as cell output, and plt.show() triggers that explicitly. pandas renders DataFrames as formatted HTML tables. If you need more interaction, libraries such as Plotly or ipywidgets can produce components that run inside the cell.

Output is saved into the file itself. That turns the document into a self-contained report, but it has two side effects: the file grows quickly, and a saved output stays there in its old form even after you change the code. Trimming large tables with head() and writing the full result to a separate file is a good middle ground.

Good notebook habits

1

One cell, one job

Keep loading, cleaning and plotting in separate cells. Both debugging and re-running get easier.

2

Don't break the order

Aim for a document that runs top to bottom. A session where you jumped back and forth is not reproducible.

3

Keep paths in one place

Define file paths and threshold values as variables in a single cell at the top.

4

Move repetition into modules

A function you have copied into two notebooks now belongs in a .py file under src/.

5

Write down dependencies

Without a requirements.txt or equivalent, the notebook will not run on another machine.

6

Strip sensitive output

Customer names, e-mails and keys get embedded in the file. Clear them before sharing.

Saving, exporting, sharing

An .ipynb file is really a JSON document: cells, outputs and kernel metadata all live inside it. That has two consequences. First, in version control (Git), output diffs produce unreadable noise, so clearing outputs before committing is a common practice. Second, when you send the file to someone, you send all of its output along with the code.

Exporting to HTML
jupyter nbconvert --to html analysis.ipynb

The generated HTML shows the output stored in the file; it does not re-run any cells. So if you export without restarting and re-running first, stale results go into the report. Run it from the top once before converting, and open the HTML afterwards to look it over.

Common problems

SymptomLikely causeWhat to do
ModuleNotFoundErrorThe kernel is not the environment you installed intoCheck sys.executable, pick the right kernel
NameError: variable undefinedCells ran out of order, or the kernel was resetRestart & Run All from the top
Output doesn't match the codeThe cell was edited but not re-runCheck the execution numbers, run from the top
File became enormousEmbedded figures and large table outputClear outputs, write big results to a file
Chart doesn't showThe figure was closed before display, or a backend issueAdd plt.show(), restart the kernel

Conclusion

The strength of Jupyter Notebook is that it makes the thinking process visible: you probe the data, write down what you see, move to the next step. That flexibility is also its biggest risk — a document with a scrambled execution order and stale output does not inspire confidence.

The practical rule is simple: keep cells small, narrate each section in a sentence, and restart the kernel and run everything before sharing. With those three habits, a notebook stops being a private scratchpad and becomes a document someone else can follow.