psifr.fr.split_lists#

psifr.fr.split_lists(frame, phase, keys=None, names=None, item_query=None, as_list=False)#

Convert free recall data from one phase to split format.

Parameters:
  • frame (pandas.DataFrame) – Free recall data with separate study and recall events.

  • phase ({'study', 'recall', 'raw'}) – Phase of recall to split. If ‘raw’, all trials will be included.

  • keys (list of str, optional) – Data columns to include in the split data. If not specified, all columns will be included.

  • names (list of str, optional) – Name for each column in the returned split data. Default is to use the same names as the input columns.

  • item_query (str, optional) – Query string to select study trials to include. See pandas.DataFrame.query for allowed format.

  • as_list (bool, optional) – If true, each column will be output as a list; otherwise, outputs will be numpy.ndarray.

Returns:

split – Data in split format. Each included column will be a key in the dictionary, with a list of either numpy.ndarray (default) or lists, containing the values for that column.

Return type:

dict of str: list

See also

table_from_lists

Convert list-format data to a table.

Examples

>>> from psifr import fr
>>> study = [['absence', 'hollow'], ['fountain', 'piano']]
>>> recall = [['absence'], ['piano', 'fountain']]
>>> raw = fr.table_from_lists([1, 1], study, recall)
>>> data = fr.merge_free_recall(raw)
>>> data
   subject  list      item  input  output  study  recall  repeat  intrusion  prior_list  prior_input
0        1     1   absence      1     1.0   True    True       0      False         NaN          NaN
1        1     1    hollow      2     NaN   True   False       0      False         NaN          NaN
2        1     2  fountain      1     2.0   True    True       0      False         NaN          NaN
3        1     2     piano      2     1.0   True    True       0      False         NaN          NaN

Get study events split by list, just including the list and item fields.

>>> fr.split_lists(data, 'study', keys=['list', 'item'], as_list=True)
{'list': [[1, 1], [2, 2]], 'item': [['absence', 'hollow'], ['fountain', 'piano']]}

Export recall events, split by list.

>>> fr.split_lists(data, 'recall', keys=['item'], as_list=True)
{'item': [['absence'], ['piano', 'fountain']]}

Raw events (i.e., events that haven’t been scored) can also be exported to list format.

>>> fr.split_lists(raw, 'raw', keys=['position'])
{'position': [array([1, 2, 1]), array([1, 2, 1, 2])]}