열 팬더에서 난 제거

코드 예제

4
0

데이터 프레임에서 na 값을 삭제하는 방법

# if you want to delete rows containing NA values
df.dropna(inplace=True)
3
0

판다 드롭 나

df = pd.DataFrame({"name": ['Alfred', 'Batman', 'Catwoman'],
...                    "toy": [np.nan, 'Batmobile', 'Bullwhip'],
...                    "born": [pd.NaT, pd.Timestamp("1940-04-25"),
...                             pd.NaT]})
>>> df
       name        toy       born
0    Alfred        NaN        NaT
1    Batman  Batmobile 1940-04-25
2  Catwoman   Bullwhip        NaT

##Drop the rows where at least one element is missing.
>>> df.dropna()
     name        toy       born
1  Batman  Batmobile 1940-04-25
1
0

Null 값을 가진 행을 생략하는 새 데이터 프레임을 반환합니다

# Returns a new DataFrame omitting rows with null values

df4.na.drop().show()
# +---+------+-----+
# |age|height| name|
# +---+------+-----+
# | 10|    80|Alice|
# +---+------+-----+
0
0

데이터 프레임에서 목록으로 변환 할 때 nan 값 삭제

a = [[y for y in x if pd.notna(y)] for x in df.values.tolist()]
print (a)
[['str', 'aad', 'asd'], ['ddd'], ['xyz', 'abc'], ['btc', 'trz', 'abd']]

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................