To get the column headers from a pydataset I know I can do this:
ds = system.dataset.toDataSet(myPyDataSet)
column_headers = ds.getColumnNames()
but is there some method of getting the headers directly from a pydataset without doing the conversion?
Hi JGJohnson,
column_headers = myPyDataSet.getUnderlyingDataset().getColumnNames()
Awesome! Thanks nick.
BTW getColumnNames() returns a list of type java.util.Collections.UnmodifiableRandomAccessList and it has no .index() method, so be sure to use .indexOf() instead.
There are probably other differences as well.
http://www.docjar.org/docs/api/java/util/Collections.UnmodifiableRandomAccessList.html
If you want the column names as a regular python list and not a java.util.Collections.UnmodifiableRandomAccessList then covert it using the “list” function like so:
column_headers = list(myPyDataSet.getUnderlyingDataset().getColumnNames())
1 Like