<p dir="auto">xref <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="62270052" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/9667" data-hovercard-type="pull_request" data-hovercard-url="/pandas-dev/pandas/pull/9667/hovercard" href="https://github.com/pandas-dev/pandas/pull/9667">#9667</a> Now we also have string methods available on the index, the possible options for <code class="notranslate">return_type</code> ('series', 'frame') are a bit confusing I think: it will be confusing for users to get a Index back even if he/she supplies <code class="notranslate">return_type='series'</code> on a Index.str.split, or to get a series back with <code class="notranslate">Series.str.split(.., return_type='index')</code>?</p>
<p dir="auto">Possible ways to make this a better API:</p>
<ol dir="auto">
<li>
<p dir="auto">An <code class="notranslate">expand</code> keyword (or another name), that indicates for <code class="notranslate">False</code>: give same dimension back (so for series/index keep it a series/index), and for <code class="notranslate">True</code>: expand series to dataframe.<br>
This would then be a duplicate for <code class="notranslate">return_type</code> of course. But the <code class="notranslate">return_type</code> was only introduced in 0.15.1 (and for <code class="notranslate">partition</code> it is still in a PR), so if we want to change this: better now than later. Or has this ship sailed?</p>
</li>
<li>
<p dir="auto">easier solution of <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/jreback/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/jreback">@jreback</a>: <code class="notranslate">return_type='same'|'expand'</code> to satisfy this need? (and can be easily back-compat) -&gt; so no need to change the name of the keyword, only the arguments.</p>
</li>
</ol>
<p dir="auto">use Tempita support to provide templates for routines in <code class="notranslate">hashtable.pyx</code>. Lots of duplicated code by dtype that can easily use fused types, so code generation is needed. Following along the lines of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="166564364" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/13716" data-hovercard-type="pull_request" data-hovercard-url="/pandas-dev/pandas/pull/13716/hovercard" href="https://github.com/pandas-dev/pandas/pull/13716">#13716</a> would be nice.</p>