Created
July 26, 2020 00:25
-
-
Save titovanton/521a310c5da6d4a64f1bc58a5236a2c5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| def csv_strip(reader): | |
| ''' | |
| Removes all rows and columns, which have only blank cells. | |
| Takes csv.reader instance. | |
| Returns numpy array of lists | |
| ''' | |
| data = np.array(list(reader)) | |
| output = data | |
| indx = 0 | |
| for item in data: | |
| if not any(item): | |
| output = np.delete(output, indx, 0) | |
| else: | |
| indx += 1 | |
| data = np.transpose(output) | |
| output = data | |
| indx = 0 | |
| for item in data: | |
| if not any(item): | |
| output = np.delete(output, indx, 0) | |
| else: | |
| indx += 1 | |
| return np.transpose(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment