Question

I want to see entire 5788 rows and 7 columns of my CSV data. I used below code and it is giving little data by stating [5788 rows x 7 columns] but showing only 10 rows and 5 columns in python prompt. How to get display of entire rows and column there?

import pandas as pd
df = pd.read_csv("BusinessData.csv")
print (df)
Was it helpful?

Solution

pandas has a max rows setting - https://pandas.pydata.org/pandas-docs/stable/user_guide/options.html

Though perhaps looking at a 5,000+ row csv in an editor, or a spreadsheet or some IDEs have a csv editor would be more useful.

OTHER TIPS

You can print all your rows by iterating over them and printing.

import pandas as pd
df = pd.read_csv("BusinessData.csv")

print(df.columns)
for index, row in df.iterrows():
    print(index, row.tolist())

You can edit the maximum number of rows displayed by PANDAS with the 'display.max_rows' option. If you want it to show all your rows, you can do:

    import pandas as pd
    df = pd.read_csv("BusinessData.csv")

    pd.set_option('display.max_rows', df.shape[0])
    print(df)

Following this article How to show all columns/rows of a Pandas Dataframe?. I normally use the following commands.

# Display all columns
pd.set_option('display.max_columns', None)

#Display all rows
pd.set_option('display.max_rows', None)

#Display all elements in each col
pd.set_option('max_colwidth', None)
Licensed under: CC-BY-SA with attribution
Not affiliated with datascience.stackexchange
scroll top