Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup new webpage for searching the DR #31

Open
larsbuntemeyer opened this issue May 27, 2024 · 1 comment
Open

setup new webpage for searching the DR #31

larsbuntemeyer opened this issue May 27, 2024 · 1 comment

Comments

@larsbuntemeyer
Copy link
Contributor

We had one in the old data request, we should reimplement that here:

See als example from IMPETUS:

@larsbuntemeyer
Copy link
Contributor Author

prototype code to create excel with one sheet per prio and a grouped overview:

import pandas as pd

cols = ['out_name', 'standard_name', 'long_name', 'cell_methods']

def human_readable(df):
    return df.groupby(cols)['frequency'].apply(list).to_frame()#.reset_index()

#df.groupby('priority').apply(human_readable, include_groups=False)
df = pd.read_csv("CORDEX-CMIP6/data-request.csv")
#human_readable(df)
sheets = {k: human_readable(v) for k, v in df.groupby('priority')}

with pd.ExcelWriter('data-request.xlsx') as writer:
    for k, v in sheets.items():
        v.to_excel(writer, sheet_name=k, index=True)
        nlevels = v.index.nlevels + len(v.columns)
        worksheet = writer.sheets[k]  # pull worksheet object
        for i in range(nlevels):
            worksheet.set_column(i, i, 40)
#        for idx, col in enumerate(v):  # loop through all columns
#            print(idx)
#            series = v[col]
#            max_len = max((
#                series.astype(str).map(len).max(),  # len of largest item
#                len(str(series.name))  # len of column name/header
#                )) + 1  # adding a little extra space
#            worksheet.set_column(idx, idx, max_len)  # set column width

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant