Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. +-------+----------+-------+
  2. | Total | Quantity | Piece |
  3. +-------+----------+-------+
  4. | 8 | 2 | 4 |
  5. | 8 | 2 | 4 |
  6. | 8 | 2 | 4 |
  7. | 8 | 2 | 4 |
  8. | 8 | 2 | 4 |
  9. | 8 | 2 | 4 |
  10. | 8 | 2 | 4 |
  11. | 8 | 2 | 4 |
  12. | 8 | 2 | 4 |
  13. +-------+----------+-------+
  14.  
  15. +-------+----------+-------+
  16. | Total | Quantity | Piece |
  17. +-------+----------+-------+
  18. | 8 | 2 | 4 |
  19. | 8 | 4 | 2 |
  20. | 8 | 2 | 4 |
  21. | 8 | 4 | 2 |
  22. | 8 | 2 | 4 |
  23. | 8 | 2 | 4 |
  24. | 8 | 4 | 2 |
  25. | 8 | 2 | 4 |
  26. | 8 | 4 | 2 |
  27. +-------+----------+-------+
  28.  
  29. import pandas as pd
  30.  
  31. data = [['Total 8rrnQuantity 2rrnPiece 4'], ['Total 8rrnQuantity 2rrnPiece 4'],['Total 8rrnPiece 2rrnQuantity 4'], ['Total 8rrnQuantity 2rrnPiece 4'], ['Total 8rrnPiece 2rrnQuantity 4'],['Total 8rrnQuantity 2rrnPiece 4'], ['Total 8rrnQuantity 2rrnPiece 4'],['Total 8rrnPiece 2rrnQuantity 4'], ['Total 8rrnQuantity 2rrnPiece 4'], ['Total 8rrnPiece 2rrnQuantity 4']]
  32. df = pd.DataFrame(data, columns = ['Information'])
  33.  
  34. df["Total"] = df["Information"].str.extract(r"Total (d+)")
  35. df["Quantity"] = df["Information"].str.extract(r"Quantity (d+)")
  36. df["Piece"] = df["Information"].str.extract(r"Piece (d+)")
  37. df.drop("Information", inplace=True, axis=1)
  38. print(df)
  39.  
  40. Total Quantity Piece
  41. 0 8 2 4
  42. 1 8 2 4
  43. 2 8 4 2
  44. 3 8 2 4
  45. 4 8 4 2
  46. 5 8 2 4
  47. 6 8 2 4
  48. 7 8 4 2
  49. 8 8 2 4
  50. 9 8 4 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement