Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.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_Python 3.x_Dataframe_Pyspark - Fatal编程技术网

Python-引用列表元素作为数据帧名称

Python-引用列表元素作为数据帧名称,python,python-3.x,dataframe,pyspark,Python,Python 3.x,Dataframe,Pyspark,如何引用列表元素作为数据帧名称 在下面的示例中,我有一个正在导入的文本文件,名为x.txt。我希望数据帧被称为x file_list = ["x"] file_list[0] = spark.read.csv(input_path + file_list[0] + ".txt", sep="|", header=True, inferSchema=True) 尝试使用此-->exec(file_list[0]+“=spark.read.csv(input_path+file_list[0]+

如何引用列表元素作为数据帧名称

在下面的示例中,我有一个正在导入的文本文件,名为x.txt。我希望数据帧被称为x

file_list = ["x"]

file_list[0] = spark.read.csv(input_path + file_list[0] + ".txt", sep="|", header=True, inferSchema=True)

尝试使用此-->exec(file_list[0]+“=spark.read.csv(input_path+file_list[0]+“.txt”,sep=“|”,header=True,inferSchema=True)”)这是否回答了您的问题?不,没有。应该有一个简单的方法来做到这一点。我正在从read.csv文件创建拼花地板文件,因此我能够完成我需要的工作,但仍然希望了解如何将df名称定义为列表中的一个元素。