如何将序列对象转换为单个字符串

2024-10-03 19:29:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一系列的id,我需要输入到谷歌表通过API。你知道吗

问题是:

  • 只接受单元格的单个字符串作为输入,而不是序列或列表
  • 需要将这个序列合并成一个用逗号分隔的字符串

系列

0   0000021
1   0000021
2   0000021
3   00df5461651
4   0000021
5   0077777777

Name: id, dtype: object

期望输出

string = "0000021, 0000021, 0000021, 00df5461651, 0000021, 0077777777"

代码


g_plat= cw.loc[cw.platform =="Google"]

g_plat = g_plat.id


insertRow = [ "Google", f"{year}/{month}/{day}" ,f"Google = {g_plat}
sheet.insert_row(insertRow, 2)


TypeError: Object of type Series is not JSON serializable



Tags: 字符串nameapiid列表stringobjectgoogle