使用Pyspark FPGrowth实现,我能够得到一个输出。 或者我有一个列表,长度如下(1)
antecedent|consequent| confidence|
+----------+----------+-------------------+
|[16492930]|[20448897]|0.09983361064891846|
或者我们可以有更长的列表(2)
-------------------+----------+-------------------+
| antecedent|consequent| confidence|
+-------------------+----------+-------------------+
|[22000477, 8212566]|[11503723]| 0.289586305278174|
由于我对Python还比较陌生,所以还未能成功地将(1)转换为可以上传到BigQuery的简单数据帧
使用to_gbq
函数gbq,我得到以下错误消息
AttributeError Traceback (most recent call last)
<ipython-input-119-f3ca65bf35d9> in <module>()
1 import pandas_gbq
----> 2 pandas_gbq.to_gbq(df, 'xxxxxxx.fpgrowth', project_id=project_id)
/usr/local/envs/py3env/lib/python3.5/site-packages/pandas_gbq/gbq.py in to_gbq(dataframe, destination_table, project_id, chunksize, verbose, reauth, if_exists, private_key, auth_local_webserver)
965 private_key=private_key)
966
--> 967 table_schema = _generate_bq_schema(dataframe)
968
969 # If table exists, check if_exists parameter
/usr/local/envs/py3env/lib/python3.5/site-packages/pandas_gbq/gbq.py in _generate_bq_schema(df, default_type)
1020
1021 fields = []
-> 1022 for column_name, dtype in df.dtypes.iteritems():
1023 fields.append({'name': column_name,
1024 'type': type_mapping.get(dtype.kind, default_type)})
AttributeError: 'list' object has no attribute 'iteritems'
现在的问题是
1)是否有人能提出一种方法,将数据帧转换为在前后列中包含字符串数据的数据帧?你知道吗
2)是否有人能帮助提出正确的代码,为数据框添加简单的行编号?我尝试了多种方法,但总是得到这样的信息:我使用的函数对于'DataFrame'
有人能帮我吗?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐