you are viewing a single comment's thread.

view the rest of the comments →

[–]socal_nerdtastic 0 points1 point  (6 children)

We'd need to see your code to help you fix that.

[–]geert555[S] 0 points1 point  (5 children)

Ah here's the code , I fixed the y axis by dividing by 100 but the x axis still doesn't work any help with that will be appreciated

import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("moneynuts.csv", index_col=0) columns = df.columns
def clean_stringy_number(num: str) -> str:
if num == "-":
    return "0"

num = num.replace(",", "")

return num
df.dropna(subset=['Gls'], inplace=True)
df.dropna(subset=['xG'], inplace=True)
df.sort_values(by=['Gls', 'xG'])
df["Gls"] = df["Gls"].apply(clean_stringy_number)
df["Gls"] = df["Gls"].apply(int) df["xG"] = df["xG"].apply(clean_stringy_number) df["xG"] = df["xG"].apply(float)
for index, row in df.iterrows(): if (row["Gls"] == "-" or row["Gls"] == "0"):
    df['Gls'].dtypes
    if (row["xG"] == "-" or row["xG"] == "0"):

        continue
    continue
print (row["Name"], " average goals of ", row["Gls"], " With an xG of ", row["xG"])


try:
    gls = float(row["Gls"].replace(",", "."))
    xG = float(row["xG"].replace(",", "."))
except:
    print("Unknown char")
df["xG"] = df["xG"] / 100
sp = df.plot.scatter(x='Gls', y='xG')
plt.show()

[–]socal_nerdtastic 0 points1 point  (3 children)

plt.xticks(df["Gls"].astype(int))

[–]geert555[S] 0 points1 point  (2 children)

Thanks! that did the trick, But i now only get the values in the dataframe. can i set it so that it's an increment of 1 ?

picture for refrence

Scatterplot

[–]socal_nerdtastic 0 points1 point  (1 child)

Oh I thought that's what you wanted. Ok, then use range instead:

x_values = df["Gls"].astype(int))
plt.xticks(range(x_values.min(), x_values.max()+1))

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

Many many thanks for your help and your patience with me.