Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #+BEGIN_SRC python :exports both :results verbatim
  2. import pandas as pd
  3. test = pd.DataFrame({'A': [1000, 1000], 'B' : [60, 100]})
  4. return test
  5. #+END_SRC
  6.  
  7. #+RESULTS:
  8. : A B
  9. : 0 1000 60
  10. : 1 1000 100
  11.  
  12. #+BEGIN_SRC python :exports both :results table
  13. import pandas as pd
  14. test = pd.DataFrame({'A': [1000, 1000], 'B' : [60, 100]})
  15. return test
  16. #+END_SRC
  17.  
  18. #+RESULTS:
  19. | A B |
  20.  
  21. | | A | B |
  22. | 0 | 1000 | 60 |
  23. | 1 | 1000 | 100 |
  24.  
  25. test = pd.DataFrame({'A': [1000, 1000], 'B' : [60, 100]}, columns=list('AB'))
  26. test.columns.name = 'foo'
  27.  
  28. #+RESULTS:
  29. : foo A B
  30. : 0 1000 60
  31. : 1 1000 100
  32.  
  33. #+BEGIN_SRC python :exports both :results table
  34. import pandas as pd
  35. import numpy
  36. test = pd.DataFrame({'A': [1000, 1000], 'B' : [60, 100]})
  37. return test.as_matrix()
  38. #+END_SRC
  39.  
  40. #+RESULTS:
  41. | 1000 | 60 |
  42. | 1000 | 100 |
  43.  
  44. #+BEGIN_SRC python :exports both :results table
  45. import pandas as pd
  46. test = pd.DataFrame({'A': [1000, 1000], 'B' : [60, 100]})
  47. return [x.split(',') for x in test.to_csv().split('n')]
  48. #+END_SRC
  49.  
  50. #+RESULTS:
  51. | | A | B |
  52. | 0 | 1000 | 60 |
  53. | 1 | 1000 | 100 |
  54. | | | |
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement