bugGNU Octave - Bugs: bug #60210, [octave forge] (dataframe)...

 
 

bug #60210: [octave forge] (dataframe) Indexing with a string that partially matches many columns fails to capture exact column name

Submitter:  Tasos Papastylianou <tpapastylianou>
Submitted:  Thu 11 Mar 2021 10:12:30 AM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  None Assigned to:  None
Originator Name:  Tasos Papastylianou Open/Closed:  * Open
Release:  * 6.2.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 11 Mar 2021 10:15:30 AM UTC, comment #2: 

Also, for context, this bug was spotted via this stackoverflow post: https://stackoverflow.com/q/66557375/4183191

I'm simply the middleman :)

Tasos Papastylianou <tpapastylianou>
Thu 11 Mar 2021 10:14:12 AM UTC, comment #1: 

Apologies, I forgot to add a title and I cannot edit this now.

Please add the following title next to the tags:

"Indexing with a string which partially matches many columns fails to capture exact column name."

Tasos Papastylianou <tpapastylianou>
Thu 11 Mar 2021 10:12:30 AM UTC, original submission:  

Indexing by column name in the dataframe package seems to attempt to match a given string to substrings in existing names (regardless of position).

This seems to create problems when using an exact column name, which also exists as a substring in another column.

E.g.


A = dataframe( [1,2;3,4;5,6;7,8], 'colnames', { 'Close', 'Close1' } );
A.Close
error: subsref.m querying name Close returned positions 1
subsref.m querying name  returned positions
error: called from
    subsref at line 94 column 21


It is unclear if this 'partial matching' behaviour (as opposed to 'exact' matching) is intentional. Perhaps this was trying to mirror R's ability for partial matching, but commented-out code (line 83) seems to suggest that it should be trying to do 'exact' matches instead.

The handling in the case of multiple matches is a bit peculiar in general. E.g. irrespective of the actual error on line 94, I note in the code that at line 86:


86: resu = df.x_data{indi}; %# extract colum;


when multiple matches have occured, and thus indi is non-scalar, as in this case, the above line produces multiple results as a comma-separated-list, but only the first item in this list is captured into resu.

This means that behaviour may change depending on the order in which the various matching column names appear in the dataframe. This may be an intentional design decision, in order to capture only the first matching column, but we can't be sure since it's not documented to point out whether this is explicitly the rationale at that line.

Tasos Papastylianou <tpapastylianou>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by siko1056 (Updated the item)
  • -email is unavailable- added by tpapastylianou (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-04-28 siko1056 Summary[octave forge](dataframe) Indexing with a string which partially matches many columns fails to capture exact column name [octave forge] (dataframe) Indexing with a string that partially matches many columns fails to capture exact column name
    2021-03-11 pantxo Carbon-CopyRemoved 87643 -
    2021-03-11 pantxo Summary[octave forge] (dataframe) Indexing with a string which partially matches many columns fails to capture exact column nam [octave forge](dataframe) Indexing with a string which partially matches many columns fails to capture exact column name
    2021-03-11 pantxo Summary[octave forge] (dataframe) [octave forge] (dataframe) Indexing with a string which partially matches many columns fails to capture exact column nam

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code