Extract value from one row pandas DataFrame
I have a dataset in a relational database format (linked by an ID across various .csv files).
I know that each data frame only contains one ID value, and I would like to know the simplest way to extract values ββfrom that string.
What I am doing now:
# the group has only one element
purchase_group = purchase_groups.get_group(user_id)
price = list(purchase_group['Column_name'])[0]
The third row bothers me as it seems ugly, however I'm not sure what the workaround is. Grouping (I think) assumes there can be multiple values ββand returns an object <class 'pandas.core.frame.DataFrame'>
, while I would like to return only a string.
+5
source to share
2 answers