Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to read csv to divide values to a few columns in Python Pandas?

I have Table in csv like below:

date col1
1 01.04.2020 111
2 05.11.2019 2
3 22.05.2018 86

But when I try to read abowe csv in Python Pandas using below code:

df= pd.read_csv("my_data.csv")

I have Data Frame like below (it does not look good):

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

;date;col1
0 1;01.04.2020;111
1 2;05.11.2019;2
2 3;22.05.2018;86

How can I modify my code to read this csv and as output have Data Frame in elegant form like in csv ?

>Solution :

It looks like your csv is using ; as a delimiter, instead of the default ,.

You might also wanna instruct pandas to use the first column as index.

Use df = pd.read_csv("my_data.csv", delimiter=';', index_col=0)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading