[英]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. 我正在尝试使用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})
在图像分类之后,我得到了数组,就像array([17, 17], dtype=int32)
,我使用了collections.counter
,就像这样: Counter({17: 2})
I need to get value 17 and 2 separately from counter({17 : 2})
for creating pandas dataframe. 我需要与counter({17 : 2})
分别获得值17和2,以创建熊猫数据框。
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 我将结果添加为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: 老实说,我不知道您要用这段代码来完成什么,但是要在te数据pic_before
仅获取一行,您需要将pic_before
和pic_after
字典转换为字符串:
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()})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.