Stuchfield
Stuchfield

Reputation: 53

How do I set dataframe names from a list of names?

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.

Upvotes: 0

Views: 312

Answers (1)

0x0fba
0x0fba

Reputation: 1620

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)

Upvotes: 1

Related Questions