简体   繁体   中英

How can i add just one row in dataframe when I convert from array to pandas.dataframe

I'm trying to classification for images with RCNN. Furthermore, I want to compare for product and its number is correct with two pictures

I got array after image's classification as like array([17, 17], dtype=int32) and I used collections.counter as like out: Counter({17: 2})

I need to get value 17 and 2 separately from counter({17 : 2}) for creating pandas dataframe.

How can I fix this problem? I hope this info will be understandable for you.

x=r['class_ids']
y=r1['class_ids']
z=np.array_equal(x,y)
import collections
pic_before=collections.Counter(x)
pic_after=collections.Counter(y)
import pandas as pd
mydict = { 'pic after uploading ':pic_before, 'pic just before sending':pic_after, 'match':z}
dict_df = pd.DataFrame({key:pd.Series(value) for key, value in 
mydict.items()})

I just want to have one row when I add this result like 17:2, 17:2, true

To be honest, I have no idea what you're trying to accomplish with this code, but to obtain only a single row in te dataframe, you need to convert the pic_before and pic_after dictionaries to strings:

x=r['class_ids']
y=r1['class_ids']
z=np.array_equal(x,y)
import collections
pic_before=collections.Counter(x)
pic_after=collections.Counter(y)
import pandas as pd
mydict = { 'pic after uploading ':str(pic_before), 'pic just before sending':str(pic_after), 'match':z}
dict_df = pd.DataFrame({key:pd.Series(value) for key, value in mydict.items()})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM