其他分享
首页 > 其他分享> > 企业数据清洗项目实践day1

企业数据清洗项目实践day1

作者:互联网

今天先把国标excel表的数据在Python里转化成了字典类型,

暂时定共分为四层,层层分类。

代码

 1 def std_excel():
 2     dict={"A":{"01":{"农业":{ "011":"谷物种植","0111":"稻谷种植"}} ,
 3                "02":{"林业":{"021":"林木育种和育苗","0211":"林木育种"}}},
 4 
 5           "B":{"06":{"煤炭开采和洗选业":{ "0610":"烟煤和无烟煤开采洗选","0620":"褐煤开采洗选"}},
 6                "07":{"石油和天然气开采业":{"0710":"石油开采","0720":"天然气开采"}}}
 7           }
 8     """
 9     {
10     "A":{
11         "01":{
12             "农业":{
13                 "011":"谷物种植",
14                 "0111":"稻谷种植"
15             }
16         },
17         "02":{
18             "林业":{
19                 "021":"林木育种和育苗",
20                 "0211":"林木育种"
21             }
22         }
23     },
24     "B":{
25         "06":{
26             "煤炭开采和洗选业":{
27                 "0610":"烟煤和无烟煤开采洗选",
28                 "0620":"褐煤开采洗选"
29             }
30         },
31         "07":{
32             "石油和天然气开采业":{
33                 "0710":"石油开采",
34                 "0720":"天然气开采"
35             }
36         }
37     }
38 }
39     """
40     layer1=dict['A']
41     print("第一层 A:\n",layer1)
42 
43     layer2 = dict['A']['01']
44     print("第二层 01:\n", layer2)
45 
46     layer3 = dict['A']['01']["农业"]
47     print("第三层 农业:\n", layer3)
48 
49     layer4 = dict['A']['01']["农业"]["011"]
50     print("第四层 011\n", layer4)
51 
52     return None
53 
54 if __name__ == '__main__':
55     # print()
56     std_excel()

 

 

 

标签:__,01,开采,实践,洗选,day1,dict,print,清洗
来源: https://www.cnblogs.com/rainbow-1/p/15439153.html