Let's say I have a list like this:
b = np.array(['a','b','c','a','b','c','a','b','c','a','b','c'])
and I wanted to insert this character in every 17th position of '\ n':
np.insert(b,b[::16],'\n')
why am I getting this error message and how can this be done differently?
ValueError: invalid literal for int() with base 10: 'a'
Many thanks
The second argument to np.insertshould be an index to place the values, you can try:
np.insert
n = 3 np.insert(b, range(n, len(b), n), "\n") # array(['a', 'b', 'c', '\n', 'a', 'b', 'c', '\n', 'a', 'b', 'c', '\n', 'a', # 'b', 'c'], # dtype='<U1')
Source: https://habr.com/ru/post/1666929/More articles:Playgrounds crash with an “unknown error” when using Swift library XML parsing - xmlWorkflow Website - Contextual Support - designКак проверить даты истечения срока действия сертификатов SSL, загруженных в контекст java - javaInstalling Visual Studio 2017 behind an enterprise proxy - proxyPreprofessional request is sent in all ways - javascriptnode_modules missing after gulp local installation - javascriptFailed to check component with service - unit-testingWindows recursive critical section not working - multithreadingparse pcap file with scapy - pythonWhat to do with the dist assembly - angularAll Articles