1

 Hi I am new with python, I am using pandas to read the csv file data, and print it. The code is shown as following:

import numpy as np

import pandas as pd

import codecs

from  pandas import Series, DataFrame

dframe = pd.read_csv("/home/vagrant/geonlp_japan_station.csv",sep=',',    
encoding="Shift-JIS")
print (dframe.head(2))

but the data is printed like as following(I just give example to show it) printed result

However, I want the data to be order with columns like as following: expect printing result

I don't know how to make the printed data be clear, thanks in advance!

1 Answer 1

1

You can check unicode-formatting and set:

pd.set_option('display.unicode.east_asian_width', True)

I test it with UTF-8 version csv:

dframe = pd.read_csv("test/geonlp_japan_station/geonlp_japan_station_20130912_u.csv") 

and it seems align of output is better.

pd.set_option('display.unicode.east_asian_width', True)
print dframe


pd.set_option('display.unicode.east_asian_width', False)
print dframe
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer, but there is the same issue, you can download the data from the following link:geonlp.ex.nii.ac.jp/dictionary/geonlp/japan_station the data file is : geonlp_japan_station_20130912_u.zip(UTF-8) geonlp_japan_station_20130912_s.zip(Shift_JIS)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.