I would like to divide pandas.Seriesthe first part of the spaces.
pd.Series.str.splitoffers a parameter nthat, according to the built-in help form, looks like this, should indicate how many sections to execute. (he speaks Both 0 and -1 will be interpreted as return all splitsin notes, but doesn’t really indicate what he is doing!)
In any case, it does not work:
>>> x = pd.DataFrame(['Split Once', 'Split Once As Well!'])
>>> x[0].str.split(n=1)
0 [Split, Once]
1 [Split, Once, As, Well!]
source
share