src/oceandata/primary_production/buitenhuis.py
def load(datadir=DATADIR, 
         filename="PP_Buitenhuisetal2013.xls"):
    """Load excel file and convert to pandas dataframe"""
    fn = os.path.join(datadir, filename)
    if not os.path.isfile(fn):
        download(datadir=datadir, filename=filename)
    df = pd.read_excel(fn)
    yearlist = [val if isinstance(val, int) else int(val[1:]) for val in list(df.Year)]
    df.Year = yearlist
    df = df[["Day", "Month", "Year", "LAT", "LONG", "Depth", "PP"]]
    df["date"] = pd.to_datetime(df[["Year", "Month", "Day"]])
    df.drop(columns=["Year","Month","Day"], inplace=True)
    df.rename(columns={"LAT":"lat", "LONG":"lon","Depth":"depth"}, inplace=True)
    mask = df["PP"].apply(lambda x: isinstance(x, str))
    df = df[~mask]
    df = df[df.PP>0]
    df.set_index("date", inplace=True)
    return df
Load excel file and convert to pandas dataframe
Load excel file and convert to pandas dataframe
Load excel file and convert to pandas dataframe
def load(datadir=DATADIR, 
         filename="PP_Buitenhuisetal2013.xls"):
    fn = os.path.join(datadir, filename)
    if not os.path.isfile(fn):
        download(datadir=datadir, filename=filename)
    df = pd.read_excel(fn)
    yearlist = [val if isinstance(val, int) else int(val[1:]) for val in list(df.Year)]
    df.Year = yearlist
    df = df[["Day", "Month", "Year", "LAT", "LONG", "Depth", "PP"]]
    df["date"] = pd.to_datetime(df[["Year", "Month", "Day"]])
    df.drop(columns=["Year","Month","Day"], inplace=True)
    df.rename(columns={"LAT":"lat", "LONG":"lon","Depth":"depth"}, inplace=True)
    mask = df["PP"].apply(lambda x: isinstance(x, str))
    df = df[~mask]
    df = df[df.PP>0]
    df.set_index("date", inplace=True)
    return df
def load ( datadir = DATADIR , filename = "PP_Buitenhuisetal2013.xls" ) : fn = os . path . join ( datadir , filename ) if not os . path . isfile ( fn ) : download ( datadir = datadir , filename = filename ) df = pd . read_excel ( fn ) yearlist = [ val if isinstance ( val , int ) else int ( val [ 1 : ] ) for val in list ( df . Year ) ] df . Year = yearlist df = df [ [ "Day" , "Month" , "Year" , "LAT" , "LONG" , "Depth" , "PP" ] ] df [ "date" ] = pd . to_datetime ( df [ [ "Year" , "Month" , "Day" ] ] ) df . drop ( columns = [ "Year" , "Month" , "Day" ] , inplace = True ) df . rename ( columns = { "LAT" : "lat" , "LONG" : "lon" , "Depth" : "depth" } , inplace = True ) mask = df [ "PP" ] . apply ( lambda x : isinstance ( x , str ) ) df = df [ ~ mask ] df = df [ df . PP > 0 ] df . set_index ( "date" , inplace = True ) return df
Load excel file and convert to pandas dataframe
Load excel file and convert to pandas dataframe
"""Load excel file and convert to pandas dataframe"""
datadir
filename