6/27/17 Notes (Fixing case sensitivity and deleting apostrophes)
- Still trying to make the names in the attendance file all uppercase
- Tried typing the number of the First Name and Last Name columns in between the brackets instead of the column name. This did not work.
- Tried typing the letter of the First Name and Last Name columns in between the brackets instead of the column name. This did not work.
- I accidentally typed two commands to make the “First Name” column all caps instead of both the first and last name columns. This worked, I only got an error when I tried to make the last name column all caps which means that there is something wrong with that column. I am going to look through it to make sure there aren’t any numbers in that column.
- I found a name with parentheses it so I deleted them. This did not work.
- I tried changing the format of all the last name cells from “general” to “text” this did not work (the format of the first name column is “general” and it works fine)
- I added a “1” to Bilal so that the cell read “Bilal1” to see if having a number in one cell would cause an error. The name appears but the 1 does not so I’m not sure if the code just deleted the 1, or if it’s not responding to the edits I’m making in the file
- I deleted the name “Bilal” and saved the edit on my file, then, cleared the outputs on the code. However, when I ran the cell, “Bilal” still appeared which means the code isn’t responding to the edits I’m making to the file.
- I deleted the Attendance file from Jupyter Notebook, and reimported it.
- Now the First Name column won’t appear which means that blank spaces mess up the code.
- I’m going to retry all the edits I made earlier but delete and reimport the code this time after every edit I make.
- Changing the format of the cells to “Text” worked!
- Now I’m going to manually find the similarity between misspelled names that I know are the same name, to give me a reference as to how similar the names should be when I find a command to make the code automatically merge similar names.
- I was comparing MOASIAH CROMARTIE to MO’ASIAH CROMARTIE but the apostrophe in the name messed up the code. I will have to find a command that deletes apostrophes in the names before I continue on.
- Here is a command I found online that I tried:
- ConfidenceS14['Full Name'].replace("'"," ")
- This didn’t give me an error, but it didn’t delete the apostrophes either
- Tried just ConfidenceS14.replace("'"," ") instead. This did not work.
- Tried replacing the apostrophe with an underscore instead of a space. This did not work.
- Tried this command:
- ConfidenceS14['Full Name'].translate(None,"'")
- This did not work
- Tried this:
- Con14 = ConfidenceS14['Full Name']
'Con14'.replace("'","_")
- This did not work.
- Tried this:
- line = ConfidenceS14['Full Name']
''.join(c for c in line if c not in "'")
- This combined a person’s last name with the next person’s first name, and did not delete the apostrophe
- Tried putting a space in between the apostrophes in the second line, this only put a space between each name
- I tried ''.join(c for c in line if c not in "A") just to see what would happen, and it did delete the As in the sequence so i need to find a new command.
- Tried:
- line = ConfidenceS14['Full Name']
line.translate(None, "'")
- There was an error with the “translate” so I researched the translate function and I found this command:
- from string import maketrans
intab = "'"
outtab = "_"
trantab = maketrans(intab, outtab)
str = ConfidenceS14['Full Name']
print str.translate(trantab)
- I got the same error as I did for the code before.
- Apparently this is happening because something in my string isn’t actually a string so I either need to fix my string, or find a new way to delete/replace the apostrophes.
Comments
Post a Comment