Ke Tian
Ke Tian

Reputation: 177

Python Pandas: print the csv data in oder with columns

 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!

Upvotes: 1

Views: 2551

Answers (1)

jezrael
jezrael

Reputation: 863156

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

Upvotes: 1

Related Questions