Click here to Skip to main content
16,022,205 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
my code is below
import pandas as pd
#Read csv file
sh = pd.read_csv(r'L:\xxx\_Data.csv')
print(sh.tail(5))	# print(df)  All of the data

row_count = sh.rows.max
col_count = sh.columns.max
print("Row Count: " + row_count)
print("Column Count: " + col_count)

When I run it, get error
AttributeError: 'DataFrame' object has no attribute 'rows'

How to fix such an error? Thanks.

What I have tried:

AttributeError: 'DataFrame' object has no attribute xxx
Posted

Always go first to the documentation where all is revealed: DataFrame — pandas 2.2.2 documentation[^].
 
Share this answer
 
If you get an error message you don't understand, google it - it's quite likely that you aren't the first to get it.

In this case, you definitely aren't: Attributeerror: 'dataframe' object has no attribute 'rows' - Google Search[^] all of the links on the first page explain why you get the problem, and what to do about it ... and would have done the same thing 8 hours ago!

Google is your friend: Be nice and visit him often. He can answer some simple questions a lot more quickly than posting them here... In future, please try to do at least basic research yourself, and not waste your time or ours.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900