idx= pd.Index(["a", "b", "c"], name="索引Index对象的名字") s = pd.Series([1,2,3],index=idx) print(s)
时间: 2023-12-04 09:04:24 浏览: 22
这段代码创建了一个名为 idx 的索引对象,包含了字符串 ["a", "b", "c"]。这个索引对象的名字被设置为 "索引Index对象的名字"。
然后,通过使用这个 idx 索引对象,创建了一个 Series 对象 s。该 Series 对象包含了值 [1, 2, 3],并且使用 idx 索引对象作为索引。
最后,使用 print 函数打印了这个 Series 对象 s。输出结果应该类似于:
```
a 1
b 2
c 3
dtype: int64
```
其中,a、b、c 是索引值,1、2、3 是对应的数值。dtype: int64 表示数值的数据类型为整数类型。
相关问题
改写为matlab: item_name = ['idx','seq','lpips'] df = pd.DataFrame(columns=item_name) value = [] s = pd.Series(value, index=df.columns) df = df.append(s, ignore_index=True) value = [] df.to_excel(outpath)
item_name = {'idx', 'seq', 'lpips'};
df = table('Size', [0, length(item_name)], 'VariableNames', item_name);
value = {};
s = struct(value, df.Properties.VariableNames);
df = [df; s];
writetable(df, outpath);
改写为matlab代码: for floder in floders: print(floder) imgname = floder.split('_')[0] idx = tinydict[imgname] value.append(idx) value.append( floder ) sum=0 imgname=floder.split('_')[0] imgs = os.listdir(floderPath+floder) for img in imgs: brisq.get_feature(floderPath+floder+'/'+img) score = brisq.get_score(floderPath+floder+'/'+img) print(score) sum = sum + score value.append(sum/frames) print(sum/frames) s = pd.Series(value, index=df.columns) df = df.append(s, ignore_index=True) value = [] df.to_excel(outpath)
value = [];
for i = 1:length(folders)
folder = folders(i).name;
disp(folder);
imgname = strsplit(folder, '_');
imgname = imgname{1};
idx = tinydict(imgname);
value(end+1) = idx;
value(end+1) = folder;
sum = 0;
imgs = dir(fullfile(folderPath, folder));
for j = 1:length(imgs)
img = imgs(j).name;
brisq.get_feature(fullfile(folderPath, folder, img));
score = brisq.get_score(fullfile(folderPath, folder, img));
disp(score);
sum = sum + score;
end
value(end+1) = sum/frames;
disp(sum/frames);
s = pd.Series(value, 'index', df.columns);
df = df.append(s, 'ignoreindex', true);
value = [];
end
writetable(df, outpath);
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)