SHARE
TWEET

Untitled

a guest Jun 19th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Farm_Name   Total Apples    Good Apples
  2. EM  18,327  14,176
  3. EE  18,785  14,146
  4. IW  635 486
  5. L   33,929  24,586
  6. NE  12,497  9,609
  7. NW  30,756  23,765
  8. SC  8,515   6,438
  9. SE  22,896  17,914
  10. SW  11,972  9,114
  11. WM  27,251  20,931
  12. Y   21,495  16,662
  13.      
  14. import pandas as pd
  15. import io
  16.  
  17. temp=u"""Farm_Name;Total Apples;Good Apples
  18. EM;18,327;14,176
  19. EE;18,785;14,146
  20. IW;635;486
  21. L;33,929;24,586
  22. NE;12,497;9,609
  23. NW;30,756;23,765
  24. SC;8,515;6,438
  25. SE;22,896;17,914
  26. SW;11,972;9,114
  27. WM;27,251;20,931
  28. Y;21,495;16,662"""
  29. #after testing replace io.StringIO(temp) to filename
  30. df = pd.read_csv(io.StringIO(temp), sep=";",thousands=',')
  31. print df
  32.    Farm_Name  Total Apples  Good Apples
  33. 0         EM         18327        14176
  34. 1         EE         18785        14146
  35. 2         IW           635          486
  36. 3          L         33929        24586
  37. 4         NE         12497         9609
  38. 5         NW         30756        23765
  39. 6         SC          8515         6438
  40. 7         SE         22896        17914
  41. 8         SW         11972         9114
  42. 9         WM         27251        20931
  43. 10         Y         21495        16662
  44.      
  45. print df.info()
  46. <class 'pandas.core.frame.DataFrame'>
  47. RangeIndex: 11 entries, 0 to 10
  48. Data columns (total 3 columns):
  49. Farm_Name       11 non-null object
  50. Total Apples    11 non-null int64
  51. Good Apples     11 non-null int64
  52. dtypes: int64(2), object(1)
  53. memory usage: 336.0+ bytes
  54. None
  55.      
  56. locale.setlocale(locale.LC_NUMERIC, '')
  57. df = df[['Farm Name']].join(df[['Total Apples', 'Good Apples']].applymap(locale.atof))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top