About the Python Pandas module output The middle ellipsis problem for each line

Source: Internet
Author: User

About Python data analysis in the Pandas module in the output, the middle of each line will have ellipses appear, and lines and lines in the middle of the ellipsis .... Problem, most of the other sites (Baidu) are written blindly, is simply copy paste the previous version, you want to know the answer to other questions you have to read the official documents.

1 #!/usr/bin/python2 #-*-coding:utf-8-*-3 ImportNumPy as NP4 ImportPandas as PD5 ImportMySQLdb6 7DF = Pd.read_csv ('C:\\users\\administrator\\desktop\\aaa.csv', encoding='gb2312')

This is my local test, first look at the effect.

Here you see a "..." ellipsis in the middle of each row, because the module displays limits on each row, in the smallest form of memory, so the ellipsis replaces the content between them.

If there are many rows of data, the Pandas module is automatically default to display only 100 rows of data, if the 100 rows, such as 120 rows, the middle of the 20 line is "... Alternative

The processing of the omitted part of the line after the pandas reading data is processed:

1 df = pd.read_csv ('c:\\users\\administrator\\desktop\\aaa.csv', encoding=  'gb2312')2 pd.set_option ('display.width')  , None)3print DF

Just add pd.set_option ('display.width', None) here, http://pandas.pydata.org/ Pandas-docs/stable/options.html I was also found in the official documentation, which has a detailed explanation, and other methods of the Set_option function.

Niang in the degree of death also can not find the relevant answer, in Google also only a few answers, and rarely appear this situation, but I met, so record the following.

If you omit between rows and rows, you only need to add:

Pd.set_option ('display.max_rows', None)

The data is also displayed with the maximum number of rows.

Here to share the operation of the Pandas module Connection database:

#!/usr/bin/python#-*-coding:utf-8-*-ImportNumPy as NPImportPandas as PDImportMySQLdb#read URL to csvData_url ='Https://raw.githubusercontent.com/mwaskom/seaborn-data/master/tips.csv'dat=pd.read_csv (data_url) Mysql_da= MySQLdb.connect (host='localhost', port=3306,user='Root', passwd='Root', db='Library name') DF= Pd.read_sql ('select * FROM table', con =mysql_da) pd.set_option ('Display.width', None) mysql_da.close ()PrintDf

This part of the content cited: https://www.cnblogs.com/zzhzhao/p/5269217.html#undefined article, this is a very good article, I also learned a lot of it, but Bo master she did not know if there is a problem with me.

Because I have encountered such a problem, so check a lot of information is not resolved, and finally in the official documents by chance to see! So share to people who don't know the answer to the same question!

About the Python Pandas module output The middle ellipsis problem for each line

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.