Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Martins Palma Perez committed May 10, 2019
1 parent d637f79 commit 977ae97
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# file GENERATED by distutils, do NOT edit
setup.cfg
setup.py
climIndices/__init__.py
climIndices/tools.py
20 changes: 10 additions & 10 deletions climIndices/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__':
Expand Down
Binary file added climIndices/tools.pyc
Binary file not shown.
Binary file removed dist/climIndices-0.1.tar.gz
Binary file not shown.
Binary file added dist/climIndices-0.2.tar.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '[email protected]', # 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',
Expand Down

0 comments on commit 977ae97

Please sign in to comment.