Ask questions about transforming the array into a pandas data frame.

Asked 2 years ago, Updated 2 years ago, 40 views

The image was classified using RCNN and the result was received as an array.

import pandas as pd
import collections

x=r['class_ids']
pic_before=collections.Counter(x)
pic_before

out : Counter({17: 2})

y=r1['class_ids']
pic_after=collections.Counter(y)
pic_after

out : Counter({17: 2})

mydict = { 'previous picture':pic_before, 'next picture':pic_after, 'matching':z}
dict_df = pd.DataFrame({key:pd.Series(value) for key, value in mydict.items()})
dict_df

An array array of 2, creates a data frame in two rows How can we write one line at a time by making the array (1,)? Is it possible to separate 17 and 2 from the output of pic_before=collections.Counter(x), Counter({17:2))?

I'd appreciate it if you could answer!

array pandas

2022-09-22 12:24

1 Answers

The result of the counter is dict.

You can get the key and value from the dict.

import collections

dt = collections.Counter(['aaaa', 'aaaa'])
dt
dict_items([('aaaa', 2)])

dt.keys()
dict_keys(['aaaa'])

dt.values()
dict_values([2])


2022-09-22 12:24

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.