filmov
tv
How to Fix the TypeError: ‘DataFrame’ object is not callable in Python (2 Examples) | Debug & Avoid
Показать описание
Python code of this video:
import pandas as pd # Load pandas
data = pd.DataFrame({'x1':range(70, 64, - 1), # Create pandas DataFrame
'x2':['a', 'b', 'c', 'a', 'b', 'c'],
'x3':[1, 7, 5, 9, 1, 5]})
print(data) # Print pandas DataFrame
data('x3').var() # Code leads to error
# TypeError: 'DataFrame' object is not callable
data['x3'].var() # Code works fine
# Out[13]: 10.266666666666666
Follow me on Social Media:
import pandas as pd # Load pandas
data = pd.DataFrame({'x1':range(70, 64, - 1), # Create pandas DataFrame
'x2':['a', 'b', 'c', 'a', 'b', 'c'],
'x3':[1, 7, 5, 9, 1, 5]})
print(data) # Print pandas DataFrame
data('x3').var() # Code leads to error
# TypeError: 'DataFrame' object is not callable
data['x3'].var() # Code works fine
# Out[13]: 10.266666666666666
Follow me on Social Media: