repository.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:pyrsss 作者: butala 项目源码 文件源码
def nc_to_dataframe(nc_fname,
                    columns=slice(None)):
    """
    Return a pandas data frame containing the information in the
    netCDF file *nc_fname*. Return it and a mapping to the header
    metadata. Use *columns* to select columns (via a list of column
    names).
    """
    root = Dataset(nc_fname)
    data = {}
    data.update({dim: root[dim][:] for dim in root.dimensions if dim != 'time'})
    index = data['time'] = map(fromJ2000, root['time'][:])
    return (PD.DataFrame(data=data, index=index)[columns],
            {x: getattr(root, x) for x in root.ncattrs()})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号