[英]Converting a column with address and coordinates to string with .astype(str) drops the coordinates
[英]applying astype(str) on necessary column only
我有一個 dataframe 說 df,它有 900 列。 當我執行df.to_parquet()
時,它給出了關鍵錯誤。 您可能會通過以下錯誤 go。只是告訴您所有"df.to_pickle"
在我的代碼中都可以正常工作
當我這樣做時,作為一種解決方法: "df.astype(str);"
它將所有列轉換為字符串,因此"df.to_parquet"
變得成功
但是但是...我不想將所有列都轉換為'str'。 我只想知道所有列具體是什么引起的問題。 所以這是我最關心的問題。 希望你們現在都明白我的問題了。
KeyError
Traceback (most recent call last)
~/.conda/envs/py3/lib/python3.6/site-packages/pyarrow/pandas_compat.py in get_logical_type(arrow_type)
68 try:
---> 69 return logical_type_map[arrow_type.id]
70 except KeyError:
NotImplementedError: struct<>
看: https://github.com/pandas-dev/pandas/issues/21228
要獲得更具體的答案,您需要提供有關數據框的更多詳細信息(列類型和最小可重現示例)。
嘗試使用df.select_dtypes(include='object')
然后,在每個選定的列上運行.astype(str)
。 這樣,您就不會將其他列轉換為字符串。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.