如何将数组中的整数值赋给字符串数组


import csv
import numpy as np
import pandas as pd
csv_file = 'Bruv.csv'
names = []
Bar = []
Price = []
with open(csv_file, 'r') as f:
reader = csv.DictReader(f)
for row in reader:
names.append(row.get('Sizes'))
Bar.append(row.get('Product'))
Price.append(row.get('Price'))
GG = pd.DataFrame()
GG['Sizes'] = names
GG['Bars'] = Bar
GG['Prices'] = Price
print(GG)
Bar=np.array(Bar).astype('str').tolist()
print("The array:", Bar)
这是我的代码,CSV是
8为: -1029

在循环中你可以这样做,

Product.append("'"+row.get('Product')+"' ="+row.get('Price')) #if u need as string
or
Product.append({ "'"+row.get('Product')+"': "+row.get('Price')+"}") #if u need as dictionary

相关内容

  • 没有找到相关文章

最新更新