Answer the question
In order to leave comments, you need to log in
How to remove single quote from pandas?
Good afternoon!
There is the following code:
import dask.dataframe
import pandas as pd
file_csv = r'D:\phone2.csv'
df = dask.dataframe.read_csv(file_csv, encoding='windows-1251', sep='\\t', engine='python')
#df.columns = df.columns.str.strip('"') #1 Попытка убрать кавычки
df.columns = df.columns.str.replace('"','') #2 Попытка
df.
phone | status
-------------------------------
"70000000000 | ok"
"71111111111 | ok"
Answer the question
In order to leave comments, you need to log in
df = pd.DataFrame([{'name': '"name1"', 'status': '"ok"'}, {'name': '"name2"', 'status': '"ok"'}])
>>> df
name status
0 "name1" "ok"
1 "name2" "ok"
>>> for col in df.columns.values:
... df[col] = df[col].str.strip('"')
...
>>> df
name status
0 name1 ok
1 name2 ok
>>> df[df.columns] = df.apply(lambda x: x.str.strip('"'))
>>> df
name status
0 name1 ok
1 name2 ok
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question