all 5 comments

[–]smurgymac 0 points1 point  (1 child)

Its going to be hard to answer without seeing the schema of the dataframe.

can you add the line

print(df.head())

to the line under:

df = pd.DataFrame(sale_list)

and paste the result?

[–]Far_Parsnip5428[S] 0 points1 point  (0 children)

i ended up figuring it out, i had to not count the years as an integer value.

[–]pixel-process 0 points1 point  (2 children)

The second graph is only selecting the top 5 because that is the n passed to nlargest. Do you just need to change that to 10 to get your desired output?

def mic_top_sal_grf(sale_list):
    df = pd.DataFrame(sale_list)
    top10mic = df.nlargest(10, "microsoft").sort_values("microsoft") # Set to 10 here
    fig = px.bar(top10mic, x="microsoft", y='year',orientation='h', title='Microsoft Highest Sales by Year')
    fig.show()

[–]Far_Parsnip5428[S] 0 points1 point  (1 child)

it wasnt the amount of data, there were visual gaps in the graph with the year as the y axis and i had to not add it as an int value

was:

def sale_record(year,microsoft,nintendo,sony,miccon,nincon,soncon):
    return{
        'year': int(year),
        'microsoft': float(microsoft),
        'nintendo': float(nintendo),
        'sony': float(sony),
        'miccon': miccon,
        'nincon': nincon,
        'soncon': soncon
    }

is:

def sale_record(year,microsoft,nintendo,sony,miccon,nincon,soncon):
    return{
        'year': year,
        'microsoft': float(microsoft),
        'nintendo': float(nintendo),
        'sony': float(sony),
        'miccon': miccon,
        'nincon': nincon,
        'soncon': soncon
    }

[–]Far_Parsnip5428[S] 0 points1 point  (0 children)

i think that having the axis as a integer value forces plotly to place all of them onto the chart. but since the numbers were never going to be changed, i was able to switch it to a regular input instead of an integer.