Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从命名数组调用数据_Python_Arrays_Database_Sorting - Fatal编程技术网

Python 从命名数组调用数据

Python 从命名数组调用数据,python,arrays,database,sorting,Python,Arrays,Database,Sorting,我正在使用python,并试图从数据集中调用和绘制数组。数据集已命名,其数据格式如下: "{'err': array([8.,8.,8.,....],dtype=float32), 'saa': array([239.93,242.02,242.28,...], dtype=float32)}" 阵列中有多个数据集。我正试着一个接一个地给他们打电话 如果您关心我如何格式化所述数组,请使用以下代码格式化它们: rows=[{'amf':amf,'err':err,'unc':unc,'saa'

我正在使用python,并试图从数据集中调用和绘制数组。数据集已命名,其数据格式如下:

"{'err': array([8.,8.,8.,....],dtype=float32), 'saa': 
array([239.93,242.02,242.28,...], dtype=float32)}"
阵列中有多个数据集。我正试着一个接一个地给他们打电话

如果您关心我如何格式化所述数组,请使用以下代码格式化它们:

rows=[{'amf':amf,'err':err,'unc':unc,'saa':saa,'time':time,'o3':o3,'sza':sza}]
with open(outfile, 'a') as f:
    writer.writerow(rows)

根据要求,以下是假设的绘图代码:

import csv
import matplotlib.pyplot as plt
import numpy as np
np.set_printoptions(threshold=np.nan)

inputfile = '/usr2/..../..../file'
data = np.genfromtxt(inputfile,delimiter = '\t')
老实说,我不知道从这里到哪里去调用列表,但我想得到一个输出,可以在这样的时间调用单个数组:

output from calling single array function:
[8., 8., 8.,....... 8., 8., 8.,]

我还希望能够将一个数组与另一个数组进行对比。我只是不确定如何单独调用每个数组。

看起来您正在尝试将具有字典格式的字符串转换为可以调用的字典。您可以使用exec()进行操作 以以下形式发挥作用:

code_to_run = 'my_dict_name = ' + my_dictionary
exec(code_to_run)

for key, val in my_dict_name.items():
    # Do whatever you want...
这将创建一个完整的代码字符串,在其中使用exec()执行。然后你就可以把我的名字叫做字典了

希望这有帮助,
Ethan

你有数组字典吗?你到底想做什么。显示你的假设绘图代码。另外,你考虑过使用熊猫吗?我没有,老实说,我现在不太熟悉熊猫应用程序。我正在用假设绘图代码编辑。谢谢!我会带着我的解决方案回到这个问题上来。