RM98
RM98

Reputation: 1

ValueError: invalid literal for int() with base 10: 'system area'

def panda_data_frame (raw_data):
    details = {}
    sample_list = [1]
    for data in raw_data:
        for key,value in raw_data[data].items():
            try:
                if key == 'Time to resolution' or key == 'activity ratio %':
                    details[key].append(float(value))
                else:
                    details[key].append(value)
            except KeyError:
                if key == 'Time to resolution' or key == 'activity ratio %':
                    details[key] = [float(value)]
                else:
                    details[key] = [value]
    print(details)
    return  pd.DataFrame(details)

 def plot3(data):
    print(data)
    df = panda_data_frame(data)
    print(df)
    df3 = df.iloc[['system area','Incident priority']]
    #df3 = df['system area','Incident Priority'] 
    print(df3)
    sns_plot3 = sns.heatmap(df3, xticklables='system area', yticklables='Incident Priority', annot=True, fmt="d")
    plt.tight_layout()
    #sns_plot.set_yticks([0, 180])
    plt.show()
    sns_plot.savefig('output3.png')   

Trying to create a heatmap with the sample data. It is showing the invalid literal value error which i think is regarding the iloc line.Please help

Upvotes: 0

Views: 112

Answers (1)

imdevskp
imdevskp

Reputation: 2223

If you are trying to select two columns, then use

df3 = df[['system area','Incident priority']]

iloc - is an integer based indexing method

If you want to use iloc method in the above case, you have to mention the 0-based index of the columns like df.iloc[:, [3,5]] assuming you want all rows and your columns are at index 3 and 5

df.iloc - use integer based selection method
: - select all rows
[3:5] - select columns at 0-based index 3 and 5

Upvotes: 1

Related Questions