【问题标题】:geting SyntaxError: invalid syntax jupyter labs [closed]获取 SyntaxError:语法无效 jupyter labs [关闭]
【发布时间】:2022-12-03 19:56:14
【问题描述】:

wring this batch of code and geting syntax exxor what seems to be the problem File \"\", line 2 if color == 1: color_sq = ^ SyntaxError: invalid syntax

def calc_color(data, color=None):
        if color   == 1: color_sq =  
                        [\'#dadaebFF\',\'#bcbddcF0\',\'#9e9ac8F0\',
                        \'#807dbaF0\',\'#6a51a3F0\',\'#54278fF0\']; 
                        colors = \'Purples\';
        elif color == 2: color_sq = 
                        [\'#c7e9b4\',\'#7fcdbb\',\'#41b6c4\',
                        \'#1d91c0\',\'#225ea8\',\'#253494\']; 
                        colors = \'YlGnBu\';
        elif color == 3: color_sq = 
                        [\'#f7f7f7\',\'#d9d9d9\',\'#bdbdbd\',
                        \'#969696\',\'#636363\',\'#252525\']; 
                        colors = \'Greys\';
        elif color == 9: color_sq = 
                        [\'#ff0000\',\'#ff0000\',\'#ff0000\',
                        \'#ff0000\',\'#ff0000\',\'#ff0000\']
        else:            color_sq = 
                        [\'#ffffd4\',\'#fee391\',\'#fec44f\',
                        \'#fe9929\',\'#d95f0e\',\'#993404\']; 
                        colors = \'YlOrBr\';
        new_data, bins = pd.qcut(data, 6, retbins=True, 
        labels=list(range(6)))
        color_ton = []
        for val in new_data:
            color_ton.append(color_sq[val]) 
        if color != 9:
            colors = sns.color_palette(colors, n_colors=6)
            sns.palplot(colors, 0.6);
            for i in range(6):
                print (\"\\n\"+str(i+1)+\': \'+str(int(bins[i]))+
                       \" => \"+str(int(bins[i+1])-1), end =\" \")
            print(\"\\n\\n   1   2   3   4   5   6\")    
        return color_ton, bins;

    标签: python


    【解决方案1】:
    【解决方案2】:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-01
    • 2022-06-14
    • 1970-01-01
    • 2019-10-12
    相关资源
    最近更新 更多