Reputation: 3502
Everything works fine,but warnings are always a bad mark that IDE points to.. so, I want to learn how to improve my coding to overcome warnings
I have a class and the methods as following:
from groupby import Groupby
import numpy as np,pandas as pd
class Plotly_Plots:
def Weather_Plots(dbconnection):
df1 = pd.read_sql('select * from weather_details', dbconnection)
df = pd.read_sql('select * from crop_data', dbconnection)
bigdata = pd.concat([df, df1], axis=1)
uniquevil = pd.DataFrame(bigdata.village.dropna().unique(), columns=['village'])
con = pd.concat([uniquevil, df1['humidity'], df1['windspeed']], axis=1)
fill = np.random.choice(con.village.dropna(), int(con.village.isna().sum()))
con.loc[con.village.isna(), 'village'] = fill
groupbyvalue='village'
fieldstoaggregate='humidity'
df=con
return Groupby.groupby_agg(df,groupbyvalue,fieldstoaggregate)
groupby.py:
class Groupby():
def groupby_agg(df,groupbyvalue,fieldstoaggregate):
datamin = df.loc[df.groupby([groupbyvalue])[fieldstoaggregate].idxmin()]
datamax = df.loc[df.groupby([groupbyvalue])[fieldstoaggregate].idxmax()]
return plotsview.weatherplot(datamin, datamax)
I am seeing this warning at loc
and groupby
as unsolved attribute refernce loc
,groupby
for class Groupby
I guess my approach is not valid to do so,how can I improve my code to overcome those warnings
sorry,I am just into classes and methods in python!!
Upvotes: 1
Views: 2108
Reputation: 1863
PyCharm seems not to recognize pandas package hence the errors.
Try invalidating caches:
File -> Invalidate Caches and restart IDE.
This question is possible duplicate of PyCharm shows unresolved references error for valid code
Upvotes: 2