['000001_2017-03-17.csv', '000001_2017-03-20.csv', '000002_2017-03-21.csv', '000002_2017-03-22.csv', '000003_2017-03-23.csv', '000004_2017-03-24.csv']
numpy array has tens of thousands of elements in total. Now I want to retain the number 000001 or the like in front of each element, and remove duplicates, leaving only a unique number. The result should be['000001','000002','000003','000004']
In addition to using the for statement, is there a more efficient way?
Let’s write NumPy~
python3
You can also write like this:
np.frompyfunc
'|S6'
is to store strings in 6 bytes'is a string
stored in 6
little-endian Unicode charactersBased on the two brothers’ writing methods
@agree and accept @xiaojieluoff
If the length of the number is fixed to the first six digits, the fastest way to write it is the first one below
Use map and anonymous functions
Output:
Run the following code and you can see that with 6 million pieces of data, map is about 0.6s faster than for
Output:
If the test data is expanded to 60 million, the gap will be even more obvious