I cannot find any resources about wether one of the following three methods for getting a list of column names is preferred over the others. The first and simplest, seems to work with my current example. Is there any reason I should not use it ?
>>> import pandas as pd >>> import numpy as np >>> df = pd.DataFrame(np.random.rand(5,3)) >>> df.columns RangeIndex(start=0, stop=3, step=1) >>> list(df.columns) [0, 1, 2] >>> df.columns.get_values().tolist() [0, 1, 2] >>> list(df.columns.get_values()) [0, 1, 2] Update
Performance - related answer here: https://stackoverflow.com/a/27236748/605328
list(df)if you hate typingmy_dataframe.columns.values.tolist()if you want speed