Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a dataset which are keyed on {"Item", "Hour of Day", "Value"}.

In the examples, I noticed that it is possible to apply functions using such as

Select[(#a > 1 &)]

But what would the slot name be for my string values above? Is there a way to interrogate a dataset for its slots?

Should I simply avoid the issue and rename them if I wish to perform such operations?

share|improve this question
    
Did you try #["Item"] and #Item as described in the docu? –  Karsten 7. Jul 19 at 18:01
1  
@Karsten7. Thanks, that does it. If you had put this as an answer, then I would be happy to close the question. –  Eric Brown Jul 19 at 18:11

1 Answer 1

up vote 10 down vote accepted

The functionality of Slot(#) got extended in Mma version 10. As described in the documentation you can use

#["Item"]

or

#Item

to pick out the elements with the key "Item".

Edit:
As pointed out in the comment by @alancalvitti

#"Item"

also works, as

#"Item" & // InputForm

#Item &

and can be used for your second key:

#"Hour of Day"
share|improve this answer
3  
For keys with protected characters need quotes in the 2nd form above: #"SUBJECT_ID" –  alancalvitti Jul 19 at 20:44
    
Quoted names are not documented for special characters (spaced cases for example). Nice Tip. +1 –  Murta Jul 19 at 21:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.