You can glue the rows in the Pandas DataFrame column using the Series.str.cat () method:
In [294]: s = df['Seen'].str.cat(sep=',') In [295]: s Out[295]: '0,1,2,3,4,5,0, 2'
You can split the CSV lines into lists:
In [304]: df['Seen'].str.split(',\s*') Out[304]: 0 [0, 1, 2, 3, 4, 5] 1 [0, 2] Name: Seen, dtype: object In [305]: df['Seen'].str.split(',\s*').sum() Out[305]: ['0', '1', '2', '3', '4', '5', '0', '2']
Frequency dictionary:
In [311]: df['Seen'].str.split(',\s*').apply(pd.Series).stack().astype(int).value_counts() Out[311]: 2 2 0 2 5 1 4 1 3 1 1 1 dtype: int64
without conversion to numbers (int):
In [312]: df['Seen'].str.split(',\s*').apply(pd.Series).stack().value_counts() Out[312]: 2 2 0 2 3 1 4 1 1 1 5 1 dtype: int64 In [313]: df['Seen'].str.split(',\s*').apply(pd.Series).stack().value_counts().to_dict() Out[313]: {'0': 2, '1': 1, '2': 2, '3': 1, '4': 1, '5': 1}
править, click it, and translate the question there, because I’ll most likely close it for non-compliance with the site rules. - Sergey Glazirin