Guest User

Untitled

a guest
Nov 23rd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. from io import StringIO
  2. import pandas
  3.  
  4. tsv = """\
  5. a,b,c,d,e,f,g
  6. 1,.1,1.1,5.551115123125783e-17,nan,inf,foo
  7. 2,.2,2.2,5.552225223225783e-27,nan,inf,foo
  8. """
  9.  
  10. df = pandas.read_csv(StringIO(tsv))
  11. df = df.astype(float, raise_on_error=False)
  12. gdf = df.groupby("g", as_index=False)
  13. print(gdf["a", "b", "c", "d", "e", "f"].sum())
  14. """
  15. g a b c d e f
  16. 0 foo 3.0 0.3 3.3 5.551115e-17 NaN inf
  17. """
Add Comment
Please, Sign In to add comment