Jump to content

Python

  • entries
    66
  • comments
    0
  • views
    992

Pandas Veri Temizleme (Preprocessing)


Doğuhan ELMA

43 views

1-) Dataframe hakkında genel bilgi:

df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 398 entries, 0 to 397
Data columns (total 9 columns):
 #   Column        Non-Null Count  Dtype  
---  ------        --------------  -----  
 0   mpg           398 non-null    float64
 1   cylinders     398 non-null    int64  
 2   displacement  398 non-null    float64
 3   horsepower    392 non-null    float64
 4   weight        398 non-null    int64  
 5   acceleration  398 non-null    float64
 6   model_year    398 non-null    int64  
 7   origin        398 non-null    object 
 8   name          398 non-null    object 
dtypes: float64(4), int64(3), object(2)
memory usage: 28.1+ KB

 

2 - ) Tüm Dataframe'den Null olan sütünların sayısını bulma:

df.isnull().sum()

Çıktı:

mpg             0
cylinders       0
displacement    0
horsepower      6
weight          0
acceleration    0
model_year      0
origin          0
dtype: int64

 

3- ) Dataframe'den Null değeri içeren hücrelerin satırlarını listeleme:

df[df.isnull().any(axis=1)]

Çıktı:

	mpg	cylinders	displacement	horsepower	weight	acceleration	model_year	origin
32	25.0	4		98.0		NaN		2046	19.0			71	usa
126	21.0	6		200.0		NaN		2875	17.0			74	usa
330	40.9	4		85.0		NaN		1835	17.3			80	europe
336	23.6	4		140.0		NaN		2905	14.3			80	usa
354	34.5	4		100.0		NaN		2320	15.8			81	europe
374	23.0	4		151.0		NaN		3035	20.5			82	usa

 

4-) Dataframe bir sütündakü verileri silme:

df.drop(['name'],axis=1,inplace=True)

 

5-) Dataframe içinde null ve ya none içeren hücrelerin bulunduğu satırları silmek için;

df.dropna(inplace=True)

 

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...