How to unpack the columns of a pandas DataFrame to multiple variables
问题 Lists or numpy arrays can be unpacked to multiple variables if the dimensions match. For a 3xN array, the following will work: import numpy as np a,b = [[1,2,3],[4,5,6]] a,b = np.array([[1,2,3],[4,5,6]]) # result: a=[1,2,3], b=[4,5,6] How can I achieve a similar behaviour for the columns of a pandas DataFrame ? Extending the above example: import pandas as pd df = pd.DataFrame([[1,2,3],[4,5,6]]) df.columns = ['A','B','C'] # Rename cols and df.index = ['i', 'ii'] # rows for clarity The