You are making call to search2rad function as search2rad(search) where search is the function. Within search2rad(), you are doing:
if distance.haversine([search.index]['geometry']['coordinates'][1],[search.index]['geometry']['coordinates'][0], t_dicc['tuits']['coordinates']['latitud'], t_dicc['tuits']['coordinates']['longitud']<=radius):
Here you have mentioned search.index. It is raising error since it is function (with no attribute as index).
I think what you want to do is to pass the value returned by search() call to search2rad(). For that, you may do:
search2rad(search())
But the cleaner way will be to do it like:
index = search()
search2rad(index)
Answer from Moinuddin Quadri on Stack Overflowpython - Django: 'module' object has no attribute 'index' - Stack Overflow
object has no attribute 'index'
python - AttributeError: 'builtin_function_or_method' object has no attribute 'index' - Stack Overflow
Why am I suddenly getting "AttributeError: 'Index' object has no attribute 'apply'"?
Import the urls.py module into your view. like this;
Copyfrom django.http import HttpResponse
from . import urls
def index(request):
return HttpResponse("Hello, world. You're at the poll index.")
Either do this :
Copyfrom lru.views import *
urlpatterns = patterns(
'',
url(r'^$', index, name='index')
)
or
Copyfrom lru import views
urlpatterns = patterns(
'',
url(r'^$', 'views.index', name='index')
)
I hope this helps.
import pandas as pd
from pandasql import sqldf
class ABC:
def __init__(self):
self.details = {'Name' : ['Ankit', 'Aishwarya', 'Shaurya', 'Shivangi'],'Age' : [23, 21, 22, 21]}
self.df = pd.DataFrame(self.details)
objAbc=ABC()
for i,rowObject in sqldf("select distinct Name from objAbc.df").iterrows():
print(rowObject.Name)
AttributeError Traceback (most recent call last) <ipython-input-21-aaba2874542d> in <module> 8 objAbc=ABC() 9 ---> 10 for i,rowObject in sqldf("select distinct Name from objAbc.df").iterrows(): 11 print(rowObject.Name) 12 ~\anaconda3\lib\site-packages\pandasql\sqldf.py in sqldf(query, env, db_uri) 154 >>> sqldf("select avg(x) from df;", locals()) 155 """ --> 156 return PandaSQL(db_uri)(query, env) ~\anaconda3\lib\site-packages\pandasql\sqldf.py in __call__(self, query, env) 56 continue 57 self.loaded_tables.add(table_name) ---> 58 write_table(env[table_name], table_name, conn) 59 60 try: ~\anaconda3\lib\site-packages\pandasql\sqldf.py in write_table(df, tablename, conn) 119 message='The provided table name \'%s\' is not found exactly as such in the database' % tablename) 120 to_sql(df, name=tablename, con=conn, --> 121 index=not any(name is None for name in df.index.names)) # load index into db if all levels are named 122 123 AttributeError: 'ABC' object has no attribute 'index'
I want to iterate through dataframe defined in class ABC using pandasql. sqldf function but Getting Error.
'ABC' object has no attribute 'index'
Not able to understand why object.property name is not working in sqldf.
PS: As per requirement it's mandatory to use sqldf of pandasql.
Please Help.
I don't understand... This exact code works for this same dataset look for different "X" variables, but now it is giving me this error...?
My code:
Import os Import pandas as pd
Os.chdir('file locations')
df = pd.read_csv('reading the file.csv') df = df.columns.str.replace(' ', '_')
def alphabet (row): If any(x in ['A', 'B', 'C'] for x in [row['alphanumeric_1'], row['alphanumeric_2]]): return 1 else: return 0
df['alphabet_yn] = df.apply(lambda row: alphabet (row), axis =1)
I don't understand why I am getting the AttributeError on the final line.
I am on my phone, so I apologize for how hard this might be to understand.