0

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.

3
  • 3
    Use a dictionary. Commented Nov 10, 2022 at 15:52
  • I'm not entirely following - dataframes don't really have names. Columns can have names, and rows can have names, but the dataframe as a whole doesn't have a name. Can you clarify the goal here? Commented Nov 10, 2022 at 16:07
  • 1
    you can use this solution from the another question python pandas: create multiple empty dataframes Commented Nov 10, 2022 at 16:56

1 Answer 1

1
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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.