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

Write single column to file (or create a single column Table) #10762

Closed
Gabriel-p opened this issue Sep 23, 2020 · 3 comments
Closed

Write single column to file (or create a single column Table) #10762

Gabriel-p opened this issue Sep 23, 2020 · 3 comments

Comments

@Gabriel-p
Copy link
Contributor

Description

I'm trying to generate a file out of a single Column object.

Expected behavior

A file with a single columns should be generated.

Actual behavior

The elements in the column are converted to columns.

Steps to Reproduce

import numpy as np
from astropy.io import ascii
from astropy.table import Table, Column
aa = np.random.uniform(0., 1., 100)
cc = Column(aa, name='data')
# Does not work
ascii.write(cc, 'data.dat')
# Converting to table has the same issue
tt = Table(cc)

System Details

Linux-5.5.0-050500-generic-x86_64-with-glibc2.10
Python 3.8.5 (default, Sep 4 2020, 07:30:14)
[GCC 7.3.0]
Numpy 1.19.1
astropy 4.0.1.post1
Scipy 1.5.2
Matplotlib 3.3.1

@pllim
Copy link
Member

pllim commented Sep 23, 2020

tt = Table([cc]) works for me.

@pllim pllim added the question label Sep 23, 2020
@Gabriel-p
Copy link
Contributor Author

It does indeed. It also works with ascii.write([cc], 'data.dat'). I think this behaviour is a bit non-intuitive, but there's no bug here so closing. Thank you!

@pllim
Copy link
Member

pllim commented Sep 23, 2020

There is an example at https://docs.astropy.org/en/latest/table/construct_table.html#list-of-columns but perhaps it is not obvious that a list is still necessary even if you only have one column. I am glad that works for you! 😄

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

No branches or pull requests

2 participants