Python Forum
How to clean the dataset? (avoid semi colons)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to clean the dataset? (avoid semi colons)
#1
Good morning to the community.
I would like to know how to clean the dataset. I don'yt know if my excel sheet "Santé3" is not well formatted or my code.

from pandas import read_csv
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import numpy.ma as ma

dataset = pd.read_csv('Santé3.csv', encoding='latin-1')
dataset

Attached Files

Thumbnail(s)
   

.csv   Santé3.csv (Size: 2.98 KB / Downloads: 213)
Reply
#2
The separator in your CSV file is ';'. The default separator for the pandas read_csv command is ','. You have to tell pandas that your CSV file uses a different separator.
lulu43366 likes this post
Reply
#3
Thank you for your reply deanhystad. What could be a good line of program to tell pandas that my CSV file uses a different separator?
Reply
#4
Read the documentation for pandas read_csv().
Reply
#5
https://pandas.pydata.org/pandas-docs/st...d_csv.html
sep
Reply
#6
As you recommended to me, I read the delimiters in pandas read_csv function and I explained that ; is the delimited used in my Excel sheet.

from pandas import read_csv
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import numpy.ma as ma

dataset = pd.read_csv('Santé3.csv', sep= ';', encoding='latin-1')
dataset
And now, it is in a better format. Thank you!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Can i clean this code ? BSDevo 8 978 Oct-28-2023, 05:50 PM
Last Post: BSDevo
  Clean Up Script rotw121 2 1,043 May-25-2022, 03:24 PM
Last Post: rotw121
  How to clean UART string Joni_Engr 4 2,543 Dec-03-2021, 05:58 PM
Last Post: deanhystad
  How to clean session mqtt SayHiii 0 2,029 Dec-09-2019, 07:56 AM
Last Post: SayHiii
  how to clean up unstarted processes? Skaperen 2 2,270 Aug-27-2019, 05:37 AM
Last Post: Skaperen
  sched.scheduler -> clean denisit 1 2,902 Nov-28-2018, 09:52 AM
Last Post: Gribouillis
  clean script by code fen1c5 8 4,749 Oct-16-2018, 05:11 AM
Last Post: volcano63
  clean up list elements and replace metalray 7 4,275 Aug-30-2018, 08:13 AM
Last Post: metalray
  Clean Data using NLTK disruptfwd8 0 3,355 May-12-2018, 11:21 PM
Last Post: disruptfwd8
  Clean up Code liamwemyss 1 3,393 Jun-07-2017, 08:36 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020