0

Two columns' values of a panda's data frame plotting incorrect result in scatter plot? While the same program is worked for a small program, and I have obtained the correct scatter plot for smaller list of lists.

I have created a data framework for printing the result of a text file output using pandas. I have also define the variables name to the indices of my data list using df.columns. I have printed all the result to verify the frame work.

enter image description here

But I am getting unlike results as my data values are different.

I have used the similar type of program to plot for a smaller list of lists. I have plotted the scatter plot which representing correct values.

enter image description here

I want the scatter plot of the column x and y from my text file. Also , is there any sample code for scatter plot between x and y values which have different values of second column('pid') with different marking style.

I have further made changes and printed each line. I have also used head(). The change and result are attached below: enter image description here

  • It looks like you're not using numbers but strings, please provide the output of `df.head().to_dict('list')` – mozway Apr 27 '23 at 08:53
  • https://i.stack.imgur.com/qVX24.png – Ritesh Sharma Apr 27 '23 at 10:05
  • This is not what I requested, don't use images of code/data, this is not reproducible – mozway Apr 27 '23 at 10:06
  • df.head().to_dict('list') has following error : AttributeError: 'list' object has no attribute 'lower' – Ritesh Sharma Apr 27 '23 at 10:07
  • Not sure what you're doing, but please read [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) and make sure to provide a reproducible input. – mozway Apr 27 '23 at 10:10
  • how do i share the result of df.head().to_dict('list')? i am writing the script of jupyter notebook. – Ritesh Sharma Apr 27 '23 at 10:12
  • I have checked it worked for these few line of dataframe. But when I have tried to plot whole column it does not produce correct result. {'nbeg': ['1', '1', '1', '1', '1'], 'pid': ['3', '-3', '3', '2', '-2'], 'theta': ['301.281', '229.353', '29.4911', '190.093', '597.198'], 'R': ['-0.490153', '-2.34734', '1.47786', '3.02244', '-0.913939'], 'x': ['265.809', '-160.735', '2.73694', '-188.745', '364.668'], 'y': ['-141.831', '-163.607', '29.3638', '22.5957', '-472.93']} – Ritesh Sharma Apr 27 '23 at 10:35

0 Answers0