1

I want to make a scatter plot in pandas the x axis is the mean and the y axis should be the index of data frame , but I couldn't proceed this is my code I got a lot of errors .

y=list(range(len(df.index)))    
df.plot(kind='scatter', x='meandf', y  )    
error : SyntaxError: positional argument follows keyword argument
Burhan Ali
  • 2,258
  • 1
  • 28
  • 38
sunny
  • 253
  • 1
  • 5
  • 15

1 Answers1

2

Try the following:

y=list(range(len(df.index)))

df.meandf.plot(x='meandf', y=y)

Or more concisely since you're plotting a Series:

df.meandf.plot(y=y)

If you need to maintain kind = 'scatter' you'll need to pass a dataframe:

df['y'] = y # create y column for the list you created
df.plot(x='a', y='y', kind='scatter', marker='.')
df.drop('y', axis=1, inplace=True)
Andrew L
  • 6,618
  • 3
  • 26
  • 30