Home > Enterprise >  How do I set dataframe names from a list of names?
How do I set dataframe names from a list of names?

Time:11-11

I have a list of pdb codes:

proteins = ['1h1p', '1h1s', '1pmn', '1q41', '1u4d_a', '1u4d_b', '1unl', '2br1']

I want to initialise an empty dataframe for each protein and name it after its code.

so I end up with 8 empty dataframes named:

dataframes = [1h1p, 1h1s, 1pmn, 1q41, 1u4d_a, 1u4d_b, 1unl, 2br1]

How do I do this?

Notes:

I've shown the dataframes as a list of dataframes, but I don't have to have them as a list I was just doing it for simplicity.

CodePudding user response:

import pandas as pd

proteins = ['1h1p', '1h1s', '1pmn', '1q41', '1u4d_a', '1u4d_b', '1unl', '2br1']
data = {k:[] for k in proteins}
df = pd.DataFrame(data)
  • Related