AATU
AATU

Reputation: 87

How to manipulate CSV. file on Jupyter Notebook

I have a CSV.file which looks just fine. Please see the picture below:

MSCI World Return in CSV.file

However, when I open the file in Jupyter Notebook, the columns are concanated. Please see below:

MSCI World Return in Jupyter Notebook

I used the following code to open the file:

import pandas as pd
MSCI = pd.read_csv("/Users/user/data/MSCI Wolrd returns.csv", header=0, index_col=0, parse_dates=True)

    MSCI.head()

How could I go about fixing this problem? How can I open the file so that the dates will be in one column and the values in the other?

Upvotes: 0

Views: 779

Answers (1)

PSKP
PSKP

Reputation: 1365

SOlution

Its because, in your data seperator is ; and pandas use default comma , as seperator.

Try this

import pandas as pd
MSCI = pd.read_csv("/Users/user/data/MSCI Wolrd returns.csv", header=0, index_col=0, parse_dates=True,sep=";")

MSCI.head()

If this solution is answer to your question then accept it else comment whats the problem.

Upvotes: 1

Related Questions