我在 GS 中有一个文档,其中自动上传了带有字符串格式数值的数据。\n在所有单元格中都有一个标记,因此我可以通过删除它来将字符串转换为数字。
\n\n\n\n当我使用 gspread 方法更新一个单元格时,它成功运行: wks.update_acell("B7", str(1939.0).replace("\'"," "))
但我想用 wks.update_cells 更改范围内的所有单元格。
\n\n在官方 gspread 文档中有一个例子:
\n\ncell_list = wks.range(\'A1:C7\')\n\nfor cell in cell_list:\n cell.value = \'O_o\'\n\n# Update in batch\nwks.update_cells(cell_list)\nRun Code Online (Sandbox Code Playgroud)\n\n在这种形式下它可以工作,但在我的情况下 cell.value = str.replace("\'","") 我收到错误:
TypeError: replace() takes at least 2 arguments (1 given)\nRun Code Online (Sandbox Code Playgroud)\n\n我想我需要将 smth 放在括号 str().replace \xe2\x80\x93 但不明白什么 \xe2\x80\xa6 谁能帮我吗?
\n\nPS\n完整代码:
\n\nimport pandas as pd\nimport numpy as np\nfrom pandas import Series,DataFrame\nfrom file4dir1 import rep\n\n\n pd.set_option(\'display.max_columns\',None)\n pd.set_option(\'display.expand_frame_repr\',False)\n pd.set_option(\'max_colwidth\',-1)\n\n mytoken=\'***\'\n project = \'***\'\n\n …Run Code Online (Sandbox Code Playgroud)