Iteratively naming Pandas columns

Diesel :

I feel like this should be super easy to do, but I can't find a solution.

I have a data file with 400 columns, none of the columns are labeled. Each set of four columns is a different experiment with different numbers of rows.

What I would like to do is label the columns something like 1.1, 1.2, 1.3, 1.4, 2.1, 2.2, 2.3... etc.

All of the solutions I've seen seem to presuppose that you have prelabeled but poorly named labels and that you just want to rename them. There must be an iterative method for doing something like this.

Arne :

You could use a DataFrame with a MultiIndex for the columns:

import pandas as pd
data = pd.DataFrame(<your data here>, 
                    columns = pd.MultiIndex.from_product([range(1, 101), range(1, 5)]))       

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=342100&siteId=1