I know this question is simple but I couldn't get it.
I have a dataframe which is called df_check like the one below
I created a dictionary using the code block below
userdic = df_check.groupby('userid')['poiid'].agg(set).to_dict()
userdict output looks like below
print(userdic)
{1337: {9943, 9996, 10202, 10616}, 1339: {10202, 10725,
11601}, 5: {9177, 9489, 10190, 10349}, 54: {123,
4,
...
My goal is to get the values of each key but I have to take them as arrays because I will be working in for loop.
My Solution to get the first key's values.
dict2list = list(userdic.values())[0]
list2array= np.array(dict2list )
When I print list2array, I get the result as below.
My expectation like this
[360448, 486401, 190984, 941599, ... ]
but output like this
array({360448, 486401, 190984, 941599, ...},dtype=object)
question from:
https://stackoverflow.com/questions/65872114/convert-dictionary-values-into-array-in-python 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…