PYTHON) How to manage Pandas data in the same format?

Asked 2 years ago, Updated 2 years ago, 46 views

Assume that you have the following code:

import pandas as pd
class_1 = pd.DataFrame({'Name':['Challe', 'MinHo', 'Muhan'],  \
                        'Age':[15, 15, 16], \
                        'Village':['MaxDown', 'OceanPark', 'HolyRiver']})

This class_1 is class 1 information, and if you want to organize class 2 information, you have to make it class_2. At my current level, yes. But if you manage your data in this way, if you have hundreds or thousands of halves, the variables increase proportionally and you feel uncomfortable managing your data.

So, if I have a lot of data in the same format, If class_info (1), class 1 information is output If class_info(2), the information in class 2 is displayed .... I want to manage my data with this concept.

I wonder if there is a way.

python pandas

2022-09-20 22:12

1 Answers

Possible with dict type variable.

class = { 1:class_1, 2:class_2, 3:class_3 }
class[1] # 1 class information data frame
class[2] #2 class information data frame
class[3]


2022-09-20 22:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.