Guest User

Untitled

a guest
Feb 14th, 2018
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. import os
  2. import pandas as pd
  3. from pandas import ExcelWriter
  4. from pandas import ExcelFile
  5.  
  6. fileName= input("Enter file name here (Case Sensitve) > ")
  7. df = pd.read_excel(fileName +'.xlsx', sheetname=None, ignore_index=True)
  8. xl = pd.ExcelFile(fileName +'.xlsx')
  9. SystemCount= len(xl.sheet_names)
  10. df1 = pd.DataFrame([])
  11.  
  12. for y in range(1, int(SystemCount)+ 1):
  13. df = pd.read_excel(xl,'System ' + str(y))
  14. df['System {0}'.format(y)] = "1"
  15. df1 = df1.append(df)
  16.  
  17. df1 = df1.sort_values(['Email'])
  18. df = df1['Email'].value_counts()
  19. df1['Count'] = df1.groupby('Email')['Email'].transform('count')
  20.  
  21. print(df1)
  22.  
  23. Email System 1 System 2 System 3 System 4
  24. test_1_@test.com NaN 1 NaN NaN
  25. test_2_@test.com NaN NaN 1 NaN
  26. test_2_@test.com 1 NaN NaN NaN
  27. test_2_@test.com NaN NaN NaN 1
  28. test_3_@test.com NaN NaN NaN NaN
  29. test_4_@test.com NaN NaN 1 NaN
  30. test_5_@test.com 1 NaN NaN NaN
  31. test_5_@test.com NaN NaN 1 NaN
  32. test_5_@test.com NaN NaN NaN 1
Add Comment
Please, Sign In to add comment