Skip to content

Return list of lists instead of series #73

@lukesmurray

Description

@lukesmurray

Returning a series of lists from the api does not add much benefit to the user.

Example

# get state dcids 
state_dcids = dc.get_places_in(pd.Series(['country/USA']), 'State')[0]
# get state names
state_names = dc.get_property_values(pd.Series(state_dcids), 'name')
# naive user tries to use boolean mask to find the state alabama
state_names[state_names == ['Alabama']]   # failure since series are supposed to be 1d

Pandas series are designed to be a 1-d array so using them to store multidimensional data may throw some people off. A user can transform a list of lists to a pandas series easily if they want. The intended use case of returning pandas series was to support column assignment in dataframes. But lists of lists can be used to create dataframe columns without any conversion to a pandas series.

I suspect the majority of operations performed on the returned series will be iterating and indexing which lists support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions