0
votes

Here is my code

Import pandas as pd
finance=pd.read_csv("C:/Users/hp/Desktop/Financial Sample.csv")

finance.Profit.describe()

And the error

AttributeError Traceback (most recent call last) in ----> 1 finance.Profit.describe() ~\Anaconda3\lib\site-packages\pandas\core\generic.py in getattr(self, name) 5177 if self._info_axis._can_hold_identifiers_and_holds_name(name): 5178 return self[name] -> 5179 return object.getattribute(self, name) 5180 5181 def setattr(self, name, value): AttributeError: 'DataFrame' object has no attribute 'Profit'

2
What is print (finance.head()) ?jezrael
Is separator , ?jezrael
need more info like a sample of a the header and example rows of the csv. also you can format your code by enveloping them in back ticksErik K

2 Answers

0
votes

according to your submitted error here is correct syntax to describe Profit Column

finance['Profit'].describe()
0
votes

This syntax will work if the column name has been parsed as how it was saved (case-sensitive):

finance['Profit'].describe()

However, sometimes the name of your column can have added characters before it after reading so the actual call might result in an error. To avoid this, you can also use .iloc()

finance.iloc[:,"(column number here, starts from 0)"].describe()