Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

pandas.Series.str.lstrip#

Series.str.lstrip(to_strip=None)[source]#

Remove leading characters.

Strip whitespaces (including newlines) or a set of specified charactersfrom each string in the Series/Index from left side.Replaces any non-strings in Series with NaNs.Equivalent tostr.lstrip().

Parameters:
to_stripstr or None, default None

Specifying the set of characters to be removed.All combinations of this set of characters will be stripped.If None then whitespaces are removed.

Returns:
Series or Index of object

See also

Series.str.strip

Remove leading and trailing characters in Series/Index.

Series.str.lstrip

Remove leading characters in Series/Index.

Series.str.rstrip

Remove trailing characters in Series/Index.

Examples

>>>s=pd.Series(['1. Ant.  ','2. Bee!\n','3. Cat?\t',np.nan,10,True])>>>s0    1. Ant.1    2. Bee!\n2    3. Cat?\t3          NaN4           105         Truedtype: object
>>>s.str.strip()0    1. Ant.1    2. Bee!2    3. Cat?3        NaN4        NaN5        NaNdtype: object
>>>s.str.lstrip('123.')0    Ant.1    Bee!\n2    Cat?\t3       NaN4       NaN5       NaNdtype: object
>>>s.str.rstrip('.!?\n\t')0    1. Ant1    2. Bee2    3. Cat3       NaN4       NaN5       NaNdtype: object
>>>s.str.strip('123.!?\n\t')0    Ant1    Bee2    Cat3    NaN4    NaN5    NaNdtype: object

[8]ページ先頭

©2009-2025 Movatter.jp