Python?Pandas刪除替換并提取其中的缺失值NaN(dropna,fillna,isnull)
前言
例如,當(dāng)使用pandas讀取csv文件時(shí),如果元素為空,則將其視為缺失值NaN(非數(shù)字)。
使用dropna()方法刪除缺失值,使用fillna()方法用其他值替換(填充)缺失值。
如果要提取包含缺失值的行或列,使用isnull()方法確定元素是否缺失。
例如,讀取并使用包含帶read_csv的空格的csv文件。
import pandas as pd
import numpy as np
import math
df = pd.read_csv('./data/05/sample_pandas_normal_nan.csv')
print(df)
# name age state point other
# 0 Alice 24.0 NY NaN NaN
# 1 NaN NaN NaN NaN NaN
# 2 Charlie NaN CA NaN NaN
# 3 Dave 68.0 TX 70.0 NaN
# 4 Ellen NaN CA 88.0 NaN
# 5 Frank 30.0 NaN NaN NaN
在此,將對以下內(nèi)容進(jìn)行說明。
- Pandas中缺失值NaN的介紹
- 將缺失值作為Pandas中的缺失值NaN
- 缺失值NaN的刪除方法
- 刪除所有值均缺失的行/列
- 刪除至少包含一個缺失值的行/列
- 根據(jù)不缺失值的元素?cái)?shù)量刪除行/列
- 刪除特定行/列中缺失值的列/行
- pandas.Series
- 替換(填充)缺失值
- 用通用值統(tǒng)一替換
- 為每列替換不同的值
- 用每列的平均值,中位數(shù),最頻繁值等替換
- 替換為上一個或下一個值
- 指定連續(xù)更換的最大數(shù)量
- pandas.Series
- 提取缺失值
- 提取特定行/列中缺少值的列/行
- 提取至少包含一個缺失值的行/列
Pandas中缺少值NaN的介紹
在Pandas中,如果列包含任何缺失值NaN,則即使所有其他值均為整數(shù)int,該列的dtype也將被視為浮點(diǎn)。
df = pd.read_csv('./data/05/sample_pandas_normal_nan.csv')
print(df)
# name age state point other
# 0 Alice 24.0 NY NaN NaN
# 1 NaN NaN NaN NaN NaN
# 2 Charlie NaN CA NaN NaN
# 3 Dave 68.0 TX 70.0 NaN
# 4 Ellen NaN CA 88.0 NaN
# 5 Frank 30.0 NaN NaN NaN
print(df.dtypes)
# name object
# age float64
# state object
# point float64
# other float64
# dtype: object
雖然編寫代碼時(shí)不必?fù)?dān)心,但是對象類型列的缺失值是內(nèi)置的float,而浮點(diǎn)類型列的缺失值是NumPy的numpy.float64。數(shù)字可能會因環(huán)境而異)。
print(df.at[1, 'name']) print(type(df.at[1, 'name'])) # nan # <class 'float'> print(df.at[0, 'point']) print(type(df.at[0, 'point'])) # nan # <class 'numpy.float64'>
使用pandas.isnull()檢查缺失的值。也可以使用numpy.isnan()和math.isnan()(但是需要分別導(dǎo)入NumPy和math)。
print(pd.isnull(df.at[0, 'point'])) print(np.isnan(df.at[0, 'point'])) print(math.isnan(df.at[0, 'point'])) # True # True # True
注意,用==與np.nan或math.nan比較會返回False。
print(df.at[0, 'point'] == np.nan) # False
將缺失值作為Pandas中的缺少值NaN
在Pandas中,將None,np.nan,math.nan和pd.np.nan視為缺失值NaN,以下所述的dropna()和fillna()。另外,只要導(dǎo)入了Pandas,pd.np.nan就可以不導(dǎo)入NumPy了。 在numpy.float64中,None也轉(zhuǎn)換為nan。
s_nan = pd.Series([None, np.nan, math.nan, pd.np.nan]) print(s_nan) # 0 NaN # 1 NaN # 2 NaN # 3 NaN # dtype: float64 print(s_nan[0]) print(type(s_nan[0])) # nan # <class 'numpy.float64'> print(s_nan.isnull()) # 0 True # 1 True # 2 True # 3 True # dtype: bool
如上所述,如果包含缺失值,則將整數(shù)int類型值強(qiáng)制轉(zhuǎn)換為浮點(diǎn)浮點(diǎn)類型。
s_nan_int = pd.Series([None, pd.np.nan, 0, 1]) print(s_nan_int) # 0 NaN # 1 NaN # 2 0.0 # 3 1.0 # dtype: float64 print(s_nan_int.isnull()) # 0 True # 1 True # 2 False # 3 False # dtype: bool
如果包含字符串str值,則其pandas.Series(和pandas.DataFrame列)數(shù)據(jù)類型將為object。 None不會轉(zhuǎn)換為numpy.float64的nan并保持為None,但是它是dropna()和fillna()的對象,因此在實(shí)踐中無需擔(dān)心。
s_nan_str = pd.Series([None, pd.np.nan, 'NaN', 'nan']) print(s_nan_str) # 0 None # 1 NaN # 2 NaN # 3 nan # dtype: object print(s_nan_str[0]) print(type(s_nan_str[0])) # None # <class 'NoneType'> print(s_nan_str.isnull()) # 0 True # 1 True # 2 False # 3 False # dtype: bool
如果有一個您想當(dāng)作缺失值的值,例如字符串“ NaN”,則可以使用replace()方法將其替換為缺失值。
s_nan_str_replace = s_nan_str.replace({'NaN': pd.np.nan, 'nan': pd.np.nan})
print(s_nan_str_replace)
# 0 NaN
# 1 NaN
# 2 NaN
# 3 NaN
# dtype: float64
print(s_nan_str_replace.isnull())
# 0 True
# 1 True
# 2 True
# 3 True
# dtype: bool
請注意,在上面的示例中,在讀取read_csv()之類的文件的函數(shù)中,空字符串(空白)和字符串’NaN’,'null’默認(rèn)情況下視為缺失值。有關(guān)詳細(xì)信息,請參見以下文章。
Pandas讀取csv/tsv文件(read_csv,read_table)
缺少值NaN的刪除方法
使用dropna()方法刪除缺失值。
默認(rèn)情況下,將返回新對象,并且不會更改原始對象,但是參數(shù)inplace = True會更改原始對象本身。 以較早加載的pandas.DataFrame為例。
print(df) # name age state point other # 0 Alice 24.0 NY NaN NaN # 1 NaN NaN NaN NaN NaN # 2 Charlie NaN CA NaN NaN # 3 Dave 68.0 TX 70.0 NaN # 4 Ellen NaN CA 88.0 NaN # 5 Frank 30.0 NaN NaN NaN
刪除所有值均缺失的行/列
如果指定了參數(shù)how =‘all’,則將刪除所有缺少值的行。
print(df.dropna(how='all')) # name age state point other # 0 Alice 24.0 NY NaN NaN # 2 Charlie NaN CA NaN NaN # 3 Dave 68.0 TX 70.0 NaN # 4 Ellen NaN CA 88.0 NaN # 5 Frank 30.0 NaN NaN NaN
如果設(shè)置axis = 1,則將刪除所有缺少值的列。
print(df.dropna(how='all', axis=1)) # name age state point # 0 Alice 24.0 NY NaN # 1 NaN NaN NaN NaN # 2 Charlie NaN CA NaN # 3 Dave 68.0 TX 70.0 # 4 Ellen NaN CA 88.0 # 5 Frank 30.0 NaN NaN
如果axis = [0,1],則會刪除所有缺失值的行和列,但是從版本0.23.0開始,將不推薦使用(不推薦使用)軸列表和元組規(guī)范。 如果要同時(shí)應(yīng)用于行和列,則可以重復(fù)應(yīng)用dropna()。
print(df.dropna(how='all').dropna(how='all', axis=1)) # name age state point # 0 Alice 24.0 NY NaN # 2 Charlie NaN CA NaN # 3 Dave 68.0 TX 70.0 # 4 Ellen NaN CA 88.0 # 5 Frank 30.0 NaN NaN
刪除至少包含一個缺失值的行/列
示例是刪除所有缺少值的行和列的數(shù)據(jù)。
df2 = df.dropna(how='all').dropna(how='all', axis=1) print(df2) # name age state point # 0 Alice 24.0 NY NaN # 2 Charlie NaN CA NaN # 3 Dave 68.0 TX 70.0 # 4 Ellen NaN CA 88.0 # 5 Frank 30.0 NaN NaN
如果指定了參數(shù)how =‘any’,則將刪除至少包含一個缺失值的行。默認(rèn)值為how =‘any’。
print(df2.dropna(how='any')) # name age state point # 3 Dave 68.0 TX 70.0 print(df2.dropna()) # name age state point # 3 Dave 68.0 TX 70.0
如果設(shè)置axis = 1,則將刪除包含至少一個缺失值的列將被刪除。
print(df2.dropna(how='any', axis=1)) # name # 0 Alice # 2 Charlie # 3 Dave # 4 Ellen # 5 Frank
根據(jù)不缺少值的元素?cái)?shù)量刪除行/列
通過在參數(shù)thresh中指定數(shù)字,可以根據(jù)不缺少值的元素?cái)?shù)量刪除行和列。
例如,如果thresh = 3,則保留包含三個或更多個不丟失值的元素的行,并刪除其他行(包含兩個或更多個不丟失值的元素的行)。
print(df.dropna(thresh=3)) # name age state point other # 0 Alice 24.0 NY NaN NaN # 3 Dave 68.0 TX 70.0 NaN # 4 Ellen NaN CA 88.0 NaN
如果axis= 1,則應(yīng)用于列。
print(df.dropna(thresh=3, axis=1)) # name age state # 0 Alice 24.0 NY # 1 NaN NaN NaN # 2 Charlie NaN CA # 3 Dave 68.0 TX # 4 Ellen NaN CA # 5 Frank 30.0 NaN
刪除特定行/列中缺少值的列/行
如果要基于特定的行/列刪除,請?jiān)诹斜淼膮?shù)子集中指定要定位的行/列標(biāo)簽。由于它必須是列表,因此請至少指定一個目標(biāo),例如subset = [‘name’]。 默認(rèn)情況下,子集指定的列中缺少值的行將被刪除。
print(df.dropna(subset=['age'])) # name age state point other # 0 Alice 24.0 NY NaN NaN # 3 Dave 68.0 TX 70.0 NaN # 5 Frank 30.0 NaN NaN NaN
如果指定了多列,則默認(rèn)為刪除所有缺少指定值的行。
print(df.dropna(subset=['age', 'state'])) # name age state point other # 0 Alice 24.0 NY NaN NaN # 3 Dave 68.0 TX 70.0 NaN
如果參數(shù)how =‘all’,則僅刪除所有指定列均缺少值的行。
print(df.dropna(subset=['age', 'state'], how='all')) # name age state point other # 0 Alice 24.0 NY NaN NaN # 2 Charlie NaN CA NaN NaN # 3 Dave 68.0 TX 70.0 NaN # 4 Ellen NaN CA 88.0 NaN # 5 Frank 30.0 NaN NaN NaN
如果axis = 1,則刪除子集指定的行中缺少值的列。參數(shù)how也可以使用。
print(df.dropna(subset=[0, 4], axis=1)) # name state # 0 Alice NY # 1 NaN NaN # 2 Charlie CA # 3 Dave TX # 4 Ellen CA # 5 Frank NaN print(df.dropna(subset=[0, 4], axis=1, how='all')) # name age state point # 0 Alice 24.0 NY NaN # 1 NaN NaN NaN NaN # 2 Charlie NaN CA NaN # 3 Dave 68.0 TX 70.0 # 4 Ellen NaN CA 88.0 # 5 Frank 30.0 NaN NaN
pandas.Series
如果數(shù)據(jù)是一維pandas.Series,則只需調(diào)用dropna()。缺少的值將被刪除。
s = df['age'] print(s) # 0 24.0 # 1 NaN # 2 NaN # 3 68.0 # 4 NaN # 5 30.0 # Name: age, dtype: float64 print(s.dropna()) # 0 24.0 # 3 68.0 # 5 30.0 # Name: age, dtype: float64
替換(填充)缺失值
可以使用fillna()方法將缺失值替換為任意值。
默認(rèn)情況下,將返回新對象,并且不會更改原始對象,但是參數(shù)inplace = True會更改原始對象本身。 以較早加載的pandas.DataFrame為例。
print(df) # name age state point other # 0 Alice 24.0 NY NaN NaN # 1 NaN NaN NaN NaN NaN # 2 Charlie NaN CA NaN NaN # 3 Dave 68.0 TX 70.0 NaN # 4 Ellen NaN CA 88.0 NaN # 5 Frank 30.0 NaN NaN NaN
用通用值統(tǒng)一替換
如果指定要用參數(shù)替換的值,則所有缺少的值NaN都將替換為該值。
print(df.fillna(0)) # name age state point other # 0 Alice 24.0 NY 0.0 0.0 # 1 0 0.0 0 0.0 0.0 # 2 Charlie 0.0 CA 0.0 0.0 # 3 Dave 68.0 TX 70.0 0.0 # 4 Ellen 0.0 CA 88.0 0.0 # 5 Frank 30.0 0 0.0 0.0
為每列替換不同的值
將字典指定為參數(shù)時(shí),每列將替換一個不同的值。字典鍵是列標(biāo)簽(列名),而值是要替換的值。未指定的列仍缺少值NaN。
print(df.fillna({'name': 'XXX', 'age': 20, 'point': 0}))
# name age state point other
# 0 Alice 24.0 NY 0.0 NaN
# 1 XXX 20.0 NaN 0.0 NaN
# 2 Charlie 20.0 CA 0.0 NaN
# 3 Dave 68.0 TX 70.0 NaN
# 4 Ellen 20.0 CA 88.0 NaN
# 5 Frank 30.0 NaN 0.0 NaN
不僅可以指定字典,還可以指定pandas.Series。具有與pandas.Series中的標(biāo)簽匹配的列標(biāo)簽(列名)的列中缺少的值將替換為pandas.Series值。與pandas.Series標(biāo)簽不對應(yīng)的列仍然缺少值。
s_for_fill = pd.Series(['ZZZ', 100], index=['name', 'age']) print(s_for_fill) # name ZZZ # age 100 # dtype: object print(df.fillna(s_for_fill)) # name age state point other # 0 Alice 24.0 NY NaN NaN # 1 ZZZ 100.0 NaN NaN NaN # 2 Charlie 100.0 CA NaN NaN # 3 Dave 68.0 TX 70.0 NaN # 4 Ellen 100.0 CA 88.0 NaN # 5 Frank 30.0 NaN NaN NaN
用每列的平均值,中位數(shù),眾數(shù)等替換
可以使用mean()方法計(jì)算每列的平均值。結(jié)果是pandas.Series。缺失值將被排除并計(jì)算。
print(df.mean()) # age 40.666667 # point 79.000000 # other NaN # dtype: float64
如果將此pandas.Series指定為fillna()的參數(shù),則如上所述,將相應(yīng)列中的缺失值替換為平均值。
print(df.fillna(df.mean())) # name age state point other # 0 Alice 24.000000 NY 79.0 NaN # 1 NaN 40.666667 NaN 79.0 NaN # 2 Charlie 40.666667 CA 79.0 NaN # 3 Dave 68.000000 TX 70.0 NaN # 4 Ellen 40.666667 CA 88.0 NaN # 5 Frank 30.000000 NaN 79.0 NaN
同樣,如果要替換中位數(shù),請使用中位數(shù)()方法。在偶數(shù)的情況下,兩個中心值的平均值是中值。
print(df.fillna(df.median())) # name age state point other # 0 Alice 24.0 NY 79.0 NaN # 1 NaN 30.0 NaN 79.0 NaN # 2 Charlie 30.0 CA 79.0 NaN # 3 Dave 68.0 TX 70.0 NaN # 4 Ellen 30.0 CA 88.0 NaN # 5 Frank 30.0 NaN 79.0 NaN
最頻繁值的取得。mode()返回pandas.DataFrame,因此iloc [0]將第一行作為pandas.Series。
print(df.fillna(df.mode().iloc[0])) # name age state point other # 0 Alice 24.0 NY 70.0 NaN # 1 Alice 24.0 CA 70.0 NaN # 2 Charlie 24.0 CA 70.0 NaN # 3 Dave 68.0 TX 70.0 NaN # 4 Ellen 24.0 CA 88.0 NaN # 5 Frank 30.0 CA 70.0 NaN
盡管在此示例中這不是問題,但是諸如mean()之類的方法可能會返回意外的值,因?yàn)槟J(rèn)情況下它們不僅嘗試處理數(shù)字列,而且還嘗試處理其他類型的列。 如果參數(shù)numeric_only = True,則目標(biāo)僅限于數(shù)字列。同樣在這種情況下,布爾類型列也被處理為True = 1,F(xiàn)alse = 0。
替換為上一個或下一個值
通過使用method參數(shù),可以替換之前和之后的值,而不是指定的值。 如果method =‘ffill’,它將被以前的值替換;如果method =‘bfill’,將被后面的值替換。對于時(shí)間序列數(shù)據(jù)很有用。
print(df.fillna(method='ffill')) # name age state point other # 0 Alice 24.0 NY NaN NaN # 1 Alice 24.0 NY NaN NaN # 2 Charlie 24.0 CA NaN NaN # 3 Dave 68.0 TX 70.0 NaN # 4 Ellen 68.0 CA 88.0 NaN # 5 Frank 30.0 CA 88.0 NaN print(df.fillna(method='bfill')) # name age state point other # 0 Alice 24.0 NY 70.0 NaN # 1 Charlie 68.0 CA 70.0 NaN # 2 Charlie 68.0 CA 70.0 NaN # 3 Dave 68.0 TX 70.0 NaN # 4 Ellen 30.0 CA 88.0 NaN # 5 Frank 30.0 NaN NaN NaN
指定連續(xù)更換的最大數(shù)量
使用參數(shù)limit,可以指定連續(xù)替換的最大數(shù)量。
print(df.fillna(method='bfill', limit=1)) # name age state point other # 0 Alice 24.0 NY NaN NaN # 1 Charlie NaN CA NaN NaN # 2 Charlie 68.0 CA 70.0 NaN # 3 Dave 68.0 TX 70.0 NaN # 4 Ellen 30.0 CA 88.0 NaN # 5 Frank 30.0 NaN NaN NaN
pandas.Series
對于pandas.Series,可以與前面的示例相同的方式進(jìn)行處理。
s = df['age']
print(s)
# 0 24.0
# 1 NaN
# 2 NaN
# 3 68.0
# 4 NaN
# 5 30.0
# Name: age, dtype: float64
print(s.fillna(100))
# 0 24.0
# 1 100.0
# 2 100.0
# 3 68.0
# 4 100.0
# 5 30.0
# Name: age, dtype: float64
print(s.fillna({1: 100, 4: 0}))
# 0 24.0
# 1 100.0
# 2 NaN
# 3 68.0
# 4 0.0
# 5 30.0
# Name: age, dtype: float64
print(s.fillna(method='bfill', limit=1))
# 0 24.0
# 1 NaN
# 2 68.0
# 3 68.0
# 4 30.0
# 5 30.0
# Name: age, dtype: float64
提取缺失值
提取特定行/列中缺少值的列/行
如果要選擇并檢查特定列中包含缺失值的行,通過isull()方法,并通過布爾索引引用進(jìn)行檢查提取。
print(df) # name age state point other # 0 Alice 24.0 NY NaN NaN # 1 NaN NaN NaN NaN NaN # 2 Charlie NaN CA NaN NaN # 3 Dave 68.0 TX 70.0 NaN # 4 Ellen NaN CA 88.0 NaN # 5 Frank 30.0 NaN NaN NaN print(df['point'].isnull()) # 0 True # 1 True # 2 True # 3 False # 4 False # 5 True # Name: point, dtype: bool print(df[df['point'].isnull()]) # name age state point other # 0 Alice 24.0 NY NaN NaN # 1 NaN NaN NaN NaN NaN # 2 Charlie NaN CA NaN NaN # 5 Frank 30.0 NaN NaN NaN
選擇在特定行中包含缺失值的列時(shí),想法是相同的。使用loc []按行名(行標(biāo)簽)選擇,并使用iloc []按位置選擇。請參見以下文章。
Pandas獲取和修改任意位置的值(at,iat,loc,iloc)
print(df.iloc[2].isnull()) # name False # age True # state False # point True # other True # Name: 2, dtype: bool print(df.loc[:, df.iloc[2].isnull()]) # age point other # 0 24.0 NaN NaN # 1 NaN NaN NaN # 2 NaN NaN NaN # 3 68.0 70.0 NaN # 4 NaN 88.0 NaN # 5 30.0 NaN NaN
提取至少包含一個缺失值的行/列
當(dāng)提取包含至少一個缺失值的行/列時(shí),而不是確定特定的行/列。
df2 = df.dropna(how='all').dropna(how='all', axis=1) print(df2) # name age state point # 0 Alice 24.0 NY NaN # 2 Charlie NaN CA NaN # 3 Dave 68.0 TX 70.0 # 4 Ellen NaN CA 88.0 # 5 Frank 30.0 NaN NaN
pandas.DataFrame isnull()方法確定每個元素是否為缺失值,并返回為True或False的pandas.DataFrame。
print(df2.isnull()) # name age state point # 0 False False False True # 2 False True False True # 3 False False False False # 4 False True False False # 5 False False True True
如果任何行或列包含True,則any方法將返回True。如果參數(shù)axis= 1,則在該行上執(zhí)行處理。
print(df2.isnull().any(axis=1)) # 0 True # 2 True # 3 False # 4 True # 5 True # dtype: bool print(df2[df2.isnull().any(axis=1)]) # name age state point # 0 Alice 24.0 NY NaN # 2 Charlie NaN CA NaN # 4 Ellen NaN CA 88.0 # 5 Frank 30.0 NaN NaN
提取列時(shí)也是如此。如果any()的參數(shù)軸設(shè)置為0,則對列執(zhí)行處理??梢允÷?,因?yàn)槟J(rèn)值為axis = 0。
print(df2.isnull().any()) # name False # age True # state True # point True # dtype: bool print(df2.loc[:, df2.isnull().any()]) # age state point # 0 24.0 NY NaN # 2 NaN CA NaN # 3 68.0 TX 70.0 # 4 NaN CA 88.0 # 5 30.0 NaN NaN
總結(jié)
到此這篇關(guān)于Python Pandas刪除替換并提取其中的缺失值NaN(dropna,fillna,isnull)的文章就介紹到這了,更多相關(guān)Pandas刪除替換提取缺失值NaN內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Pandas?多進(jìn)程處理數(shù)據(jù)提高速度
這篇文章主要介紹了Pandas?多進(jìn)程處理數(shù)據(jù)提高速度,Pandas多進(jìn)程的方法,pandarallel?庫,下面具體的測試方法,需要的朋友可以參考一下,希望對你的學(xué)習(xí)有所幫助2022-04-04
基于Python實(shí)現(xiàn)身份證信息識別功能
身份證是用于證明個人身份和身份信息的官方證件,在現(xiàn)代社會中,身份證被廣泛應(yīng)用于各種場景,如就業(yè)、教育、醫(yī)療、金融等,它包含了個人的基本信息,本文給大家介紹了如何基于Python實(shí)現(xiàn)身份證信息識別功能,感興趣的朋友可以參考下2024-01-01
解決pycharm中導(dǎo)入自己寫的.py函數(shù)出錯問題
今天小編就為大家分享一篇解決pycharm中導(dǎo)入自己寫的.py函數(shù)出錯問題,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-02-02
Python數(shù)據(jù)挖掘中常用的五種AutoEDA 工具總結(jié)
大家好,我們都知道在數(shù)據(jù)挖掘的過程中,數(shù)據(jù)探索性分析一直是非常耗時(shí)的一個環(huán)節(jié),但也是繞不開的一個環(huán)節(jié),本篇文章帶你盤點(diǎn)數(shù)據(jù)挖掘中常見的5種 AutoEDA 工具2021-11-11
python實(shí)現(xiàn)向微信用戶發(fā)送每日一句 python實(shí)現(xiàn)微信聊天機(jī)器人
這篇文章主要為大家詳細(xì)介紹了python實(shí)現(xiàn)向微信用戶發(fā)送每日一句,python調(diào)實(shí)現(xiàn)微信聊天機(jī)器人,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-03-03
Python使用方法重載實(shí)現(xiàn)訪問者模式
這篇文章主要為大家詳細(xì)介紹了Python如何使用方法重載實(shí)現(xiàn)訪問者模式,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2024-12-12
Python enumerate函數(shù)功能與用法示例
這篇文章主要介紹了Python enumerate函數(shù)功能與用法,結(jié)合實(shí)例形式分析了enumerate函數(shù)針對列表、字符串遍歷操作相關(guān)使用技巧,需要的朋友可以參考下2019-03-03

