Enhancement Request:
- InStr Comparison between two values on the same row in the same DataFrame
Would be great if pandas would enable some 'instr' functionality between two columns.
For instance, being able to tell when the contents of one value exist in another:
- Excel does this in the following manner:
=instr(0, a1&"."&b1, c1, vbTextCompare)
- In Teradata SQL (not ansi compliant):
select databsename, tablename, requeststring,
index(createstring, databasename||'.'||tablename)
from dbc.tables;
Comment From: jreback
pls show an explict example of an input and output frame.
Comment From: vlstrode
Explicit Example: - Sample Data - createstring = "i am.a string. i am.a star" - databasename = 'i am' - tablename = 'a' - Sample Call (return first occurrence - df.instr(['createstring'], ['databasename']||'.'||['tablename']) returns 1 - df.instr(['createstring'], ['tablename]) returns 4
Output represents the first occurrence of the searched for string.
Comment From: jreback
this is a simple string operation
http://pandas.pydata.org/pandas-docs/stable/text.html
Comment From: jorisvandenbossche
@vlstrode I think you are looking for str.find
(https://docs.python.org/3/library/stdtypes.html#str.find), which is also available on a Series (Series.str.find
)