title: Replace character in multiple columns of panda dataframe
body: <p>I have a dataframe that I create by reading a XLSX file and I need to replace a lot of dot by commas because I don't know why in Excel it shows a comma but in panda dataframe it is a dot instead for decimal separator. I have 29 columns to replace dot by commas, so I figured out it would be better to use a list to store all my columns name and a for loop to iterate though all the column where I want to replace those dots by commas.</p>
  <p>But unfortunately I got error when I tried the following code :</p>
  <pre><code>import tkinter as tk
  from tkinter import filedialog
  from tkinter import messagebox
  import win32com.client
  import pandas as pd
  import pathlib
  
  root = tk.Tk()
  
  canvas1 = tk.Canvas(root, width=300, height=300, bg='lightsteelblue2', relief='raised')
  canvas1.pack()
  
  label1 = tk.Label(root, text='File Conversion Tool', bg='lightsteelblue2')
  label1.config(font=('helvetica', 20))
  canvas1.create_window(150, 60, window=label1)
  
  read_file = pd.DataFrame()
  
  
  def get_excel_onefolder():
      global read_file
      import_dir_path = filedialog.askdirectory()
      file_ext = &quot;*.xlsx&quot;
      list_xlsx_file = list(pathlib.Path(import_dir_path).glob(file_ext))
      lst_rpl = ['col24', 'col25', 'col26', 'col45', 'col46', 'col47', 'col69', 'col75', 'col76', 'col77', 'col105', 'col106',
                 'col107', 'col108', 'col109', 'col110', 'col111', 'col112', 'col254', 'col255', 'col256', 'col257', 'col258',
                 'col259', 'col260', 'col261', 'col262', 'col352', 'col353']
      len_lst = len(lst_rpl)
      for xlsx_file_path in list_xlsx_file:
          read_file = pd.read_excel(xlsx_file_path)
          read_file['Time'] = read_file['Time'].str.replace(',', '.')
          for i in range(len_lst):
              read_file[lst_rpl[i]] = read_file[lst_rpl[i]].str.replace('.', ',')
          output_path = str(xlsx_file_path) + &quot;.csv&quot;
          read_file.to_csv(output_path, index=None, header=True, decimal=',', sep=';')
      tk.messagebox.showinfo(title=&quot;Import success&quot;, message=&quot;CSV file import successful !&quot;)
  
  
  XLSX_to_CSV = tk.Button(text=&quot;Import Excel File &amp; Convert to CSV&quot;, command=get_excel_onefolder, bg='green', fg='white', font=('helvetica', 12, 'bold'))
  canvas1.create_window(150, 180, window=XLSX_to_CSV)
  
  root.mainloop()
  </code></pre>
  <p>The error I got is KeyError: 'col24'</p>
  <p>Edit :
  I fixed my problem by adding argument for NaN value, na_values to .read_excel with decimal=',' and it works fine now</p>
  <pre><code>read_file = pd.read_excel(xlsx_file_path, decimal=',', na_values=['#NV', ' '])
  </code></pre>
  <p>My problem was because I had column which was not recognized as float because of NaN value.</p>
  <p>The working function is now :</p>
  <pre><code>def get_excel_onefolder():
      global read_file
      import_dir_path = filedialog.askdirectory()
      file_ext = &quot;*.xlsx&quot;
      list_xlsx_file = list(pathlib.Path(import_dir_path).glob(file_ext))
      for xlsx_file_path in list_xlsx_file:
          read_file = pd.read_excel(xlsx_file_path, decimal=',', na_values=['#NV', ' '])
          read_file['Time'] = read_file['Time'].str.replace(',', '.')
          path_without_ext = os.path.splitext(str(xlsx_file_path))[0]
          output_path = path_without_ext + &quot;.csv&quot;
          read_file.to_csv(output_path, index=None, header=True, decimal=',', sep=';')
      tk.messagebox.showinfo(title=&quot;Import success&quot;, message=&quot;CSV file import successful !&quot;)
  </code></pre>