删除 Pandas 数据框中的方括号符号

时间:2021-06-28 17:30:06

标签: python-3.x pandas

我有一个 10 列的 df,其中的行作为单个元素列表插入。如何从所有行中删除“[]”?

我尝试过一列:df['DAT'] = df['DAT'].map(lambda x: x.replace('[]',''))

2 个答案:

答案 0 :(得分:2)

通过 Launching lib/main.dart on Linux in debug mode... lib/main.dart:1 [xcb] Unknown sequence number while processing queue [xcb] Most likely this is a multi-threaded client and XInitThreads has not been called [xcb] Aborting, sorry about that. food_delivery: xcb_io.c:269: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed. Error waiting for a debug connection: The log reader stopped unexpectedly. Error launching application on Linux. Exited (sigterm) flutter clean

astype()

尝试使用 strip()df['DAT'] = df['DAT'].astype(str).str.strip("['']")

pd.eval()

答案 1 :(得分:1)

使用checkForWinX

>>> "X" == "Χ"
False

>>> "X".encode('utf-8') # this is the one you use in checkForWinX
b'X'
>>> "Χ".encode('utf-8') # this is the one you assign to mainList[row][chosenColumn]
b'\xce\xa7'
相关问题