By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,496 Members | 1,517 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,496 IT Pros & Developers. It's quick & easy.

I want to return vector of true, false by comparing two values

P: 1
Expand|Select|Wrap|Line Numbers
  1. import pandas as pd
  2. import numpy as np
  3.  
  4.  
  5. #Dataset 1
  6. path="D:\\Data Science\\Python-Piyush\\Interview practice\\age.csv"
  7. age=pd.read_csv(path)
  8. age.head()
  9.  
  10. #1) To find mean age of dataset
  11. a=(round(np.mean(age),5))
  12. print(type(a))
  13. print(a)
  14.  
  15. import pandas as pd
  16. import numpy as np
  17.  
  18.  
  19. #Dataset 1
  20. path="D:\\Data Science\\Python-Piyush\\Interview practice\\age.csv"
  21. age=pd.read_csv(path)
  22. age.head()
  23.  
  24. #1) To find mean age of dataset
  25. a=(round(np.mean(age),5))
  26. print(type(a))
  27. print(a)
  28.  
  29. #2)NO of entries that have age less than mean age 
  30. for i in age['Age']:
  31.     y=i<a
  32.     print(y)
  33.     print(type(y))
  34.  
  35.     c=y.value_counts('True')for i in age['Age']:
  36.     y=i<a
  37.     print(y)
  38.     print(type(y))
  39.  
  40.     c=y.value_counts('True')
Oct 16 '19 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.