diff --git a/MANIFEST b/MANIFEST index e22d8f4..192d4ea 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,4 +1,5 @@ # file GENERATED by distutils, do NOT edit setup.cfg setup.py +climIndices/__init__.py climIndices/tools.py diff --git a/climIndices/tools.py b/climIndices/tools.py index a392645..a1fd532 100644 --- a/climIndices/tools.py +++ b/climIndices/tools.py @@ -45,13 +45,13 @@ def get_data(index, source = 'NOAA'): call(["curl","-s", "-o", 'temp.txt', URL], stdout=open(os.devnull, 'wb')) flen = file_len('temp.txt') - df = pd.read_csv('temp.txt',sep='\s+', skiprows=[0,flen-1]) + df = pd.read_csv('temp.txt',sep='\s+', skiprows=[0,flen-1, flen-2]) call(['rm', 'temp.txt']) - df = format_data(df) + df = format_data(df, index) return df -def format_data(df): +def format_data(df, index): colnames=['year'] [colnames.append(i) for i in range(1,13)] df.columns=colnames @@ -63,14 +63,14 @@ def format_data(df): df = df.replace('-99.99', np.NaN) df = df.dropna() - print(df) - print('{year}-{month}-31'.format(year=df['year'].iloc[-1], month=df['month'].iloc[-1])) - indexes = pd.date_range(start='{year}-{month}-01'.format(year=df['year'].iloc[0], month=df['month'].iloc[0]), - end='{year}-{month}-31'.format(year=df['year'].iloc[-1], month=df['month'].iloc[-1]),freq='M') - print(indexes) + indexes = pd.date_range(start='{year:0d}-{month}-01'.format(year=int(df['year'].iloc[0]), month=int(df['month'].iloc[0])), + end='{year:0d}-{month}-31'.format(year=int(df['year'].iloc[-1]), month=int(df['month'].iloc[-1])),freq='M') df['time']=indexes - df = df.set_index(time) - df=df.dropna() + df = df.set_index('time') + df = df.drop(['month','year'], axis=1) + df.columns = [index] + df = df.replace(-99.99, np.NaN) + df = df.dropna() return df if __name__=='__main__': diff --git a/climIndices/tools.pyc b/climIndices/tools.pyc new file mode 100644 index 0000000..744c2b7 Binary files /dev/null and b/climIndices/tools.pyc differ diff --git a/dist/climIndices-0.1.tar.gz b/dist/climIndices-0.1.tar.gz deleted file mode 100644 index 3fdc019..0000000 Binary files a/dist/climIndices-0.1.tar.gz and /dev/null differ diff --git a/dist/climIndices-0.2.tar.gz b/dist/climIndices-0.2.tar.gz new file mode 100644 index 0000000..3d5dcb7 Binary files /dev/null and b/dist/climIndices-0.2.tar.gz differ diff --git a/setup.py b/setup.py index 11cb890..b47a557 100644 --- a/setup.py +++ b/setup.py @@ -3,13 +3,13 @@ setup( name = 'climIndices', # How you named your package folder (MyLib) packages = ['climIndices'], # Chose the same as "name" - version = '0.1', # Start with a small number and increase it with every change you make + version = '0.2', # Start with a small number and increase it with every change you make license='MIT', # Chose a license from here: https://help.github.com/articles/licensing-a-repository description = 'Methods to download and format NOAA climate indices', # Give a short description about your library author = 'Gabriel Perez', # Type in your name author_email = 'gabrielmpp2@gmail.com', # Type in your E-Mail url = 'https://github.com/gabrielmpp/climate_indices', # Provide either the link to your github or to your website - download_url = 'https://github.com/gabrielmpp/climate_indices/archive/v0.1.tar.gz', # I explain this later on + download_url = 'https://github.com/gabrielmpp/climate_indices/archive/v0.2.tar.gz', # I explain this later on keywords = ['climate', 'pandas'], # Keywords that define your package best install_requires=[ # I get to this in a second 'pandas',