1

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!!

KcH
  • 3,302
  • 3
  • 21
  • 46
  • "I have a class and the methods" You have functions inside non-functional classes with no attributes. Do you have an actual problem with methods and classes -- or with PyCharm not recognising members of the ``pandas`` module? – MisterMiyagi Sep 14 '19 at 18:55
  • @MisterMiyagi , I think the more I am worried is about methods and classes , as you mentioned it clearly ` functions inside non-functional classes with no attributes`, How can i make the whole stuff with a class and methods? The thing I am doing is converting a sql to dataframe and some operations and later I want to groupby (as groupby would be a common operation I wanted to be in separate reusable code) also sql to dataframe would be same for all,.....can this be achieved with a class and methods or simply what I tried would be enough ? – KcH Sep 15 '19 at 07:00

1 Answers1

2

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

stasiekz
  • 1,775
  • 5
  • 22