1

I am currently trying to have my .csv imported in Python via Pandas. Some of the data properly shows up, but it's only the first 5 rows and then the last 5 rows.

I have about 3,000 rows that I want to show up, but cannot find a viable solution.

I am linking a screenshot and there is a copy of my code too. Thanks for the help! Output of running code

import pandas as pd
data = pd.read_csv("ChicagoCrime2001.csv")
df = pd.DataFrame(data, columns= ['Block', 'Primary Type'])
print(df)
LakenBRION
  • 11
  • 2

3 Answers3

0

You can use df.to_string() to display all results.


pandas.DataFrame.to_string

Render a DataFrame to a console-friendly tabular output.

Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268
0

try to use set_options

import pandas as pd
pd.set_option("display.max_rows", None, "display.max_columns", None)
df = pd.DataFrame(data, columns= ['Block', 'Primary Type'])
print(df)
Rajith Thennakoon
  • 3,975
  • 2
  • 14
  • 24
0

This is the default behavior when printing pandas.DataFrame.

with pd.option_context('display.max_rows', None, 'display.max_columns', None):  # more options can be specified also
    print(df)

see Pretty-print an entire Pandas Series / DataFrame for additional details.

Jim
  • 668
  • 8
  • 22