I can t get a graph out of my information

0 votes
plt.subplot(3, 2, 1)
plt.scatter(child[child.Sex=='FEV (litres)']['female'], child[child.Sex=='FEV (litres)']['male'],label='Smoker',color='purple' )
plt.xlabel('female')
plt.ylabel('male')
plt.title('Smoker')
plt.subplot(3,2,2)
plt.scatter(child[child.Smoker=='FEV (litres)']['none'],child[child.Smoker=='FEV (litres)']['smoker'], marker='P')
plt.xlabel('non')
plt.ylabel('smoker')
plt.title('Smokers')

KeyError                                  Traceback (most recent call last)
~\anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
   2645             try:
-> 2646                 return self._engine.get_loc(key)
   2647             except KeyError:
pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'female'
During handling of the above exception, another exception occurred:
KeyError                                  Traceback (most recent call last)
<ipython-input-20-b062fba68450> in <module>
      1 plt.subplot(3, 2, 1)
----> 2 plt.scatter(child[child.Sex=='FEV (litres)']['female'], child[child.Sex=='FEV (litres)']['male'],label='Smoker',color='purple' )
      3 plt.xlabel('female')
      4 plt.ylabel('male')
      5 plt.title('Smoker')
~\anaconda3\lib\site-packages\pandas\core\frame.py in __getitem__(self, key)
   2798             if self.columns.nlevels > 1:
   2799                 return self._getitem_multilevel(key)
-> 2800             indexer = self.columns.get_loc(key)
   2801             if is_integer(indexer):
   2802                 indexer = [indexer]
~\anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
   2646                 return self._engine.get_loc(key)
   2647             except KeyError:
-> 2648                 return self._engine.get_loc(self._maybe_cast_indexer(key))
   2649         indexer = self.get_indexer([key], method=method, tolerance=tolerance)
   2650         if indexer.ndim > 1 or indexer.size > 1:
pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'female'
Jun 11, 2020 in Python by anonymous
• 120 points

edited Jun 11, 2020 by MD 603 views

1 answer to this question.

0 votes

Hi@lzzy,

According to your error, there is a problem with your data set. You may have unwanted space or comma in your female column. Try to check your schema properly and remove the unwanted characters. It will work.

answered Jun 11, 2020 by MD
• 95,440 points

Related Questions In Python

0 votes
1 answer

How can I get the domain name of my site within a Django template?

Hello kartik, The variation of the context processor ...READ MORE

answered Apr 23, 2020 in Python by Niroj
• 82,880 points
9,328 views
0 votes
0 answers
0 votes
1 answer

How can I get a list of locally installed Python modules?

Solution My 50 cents for getting a pip freeze-like ...READ MORE

answered May 24, 2018 in Python by charlie_brown
• 7,720 points
994 views
0 votes
2 answers

How can I get the count of a list in Python?

n=[1,2,3,4,5,6,7,8,9] print(len(n)) =9 READ MORE

answered Dec 10, 2020 in Python by anonymous
1,167 views
+1 vote
1 answer

How to create plots using python matplotlib in IPython notebook?

I think you should try: I used %matplotlib inline in ...READ MORE

answered Aug 8, 2018 in Python by Priyaj
• 58,090 points
1,189 views
+1 vote
1 answer

How to save graph using matplotlib library?

Hi@akhtar, You can find one function called savefig ...READ MORE

answered May 21, 2020 in Python by MD
• 95,440 points
1,233 views
0 votes
1 answer

ImportError: No module named matplotlib.pyplot

Hi@akhtar, It seems you don't have matplotlib library ...READ MORE

answered Jun 22, 2020 in Python by MD
• 95,440 points
24,354 views
0 votes
1 answer

Error: Can't import matplotlib library.

Install the older version of python, I also ...READ MORE

answered Nov 6, 2020 in Python by Gitika
• 65,910 points
914 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP