I am trying to convert columns 0 to 4 and 6 to int from existing float types.
I tried:
df[0:4,6].astype(int)
but of course this does not work ...
consider df
df
df = pd.DataFrame(np.random.rand(10, 10) * 10)
use np.r_to getslc
np.r_
slc
slc = np.r_[0:4, 6] df[slc] = df[slc].astype(int) df
or pass a type dictionary with keys as column names
df.astype({c: int for c in slc})
Source: https://habr.com/ru/post/1662205/More articles:Checking for duplicate items in lists in a dictionary in Python - pythonUsing the find () function with two vectors - findif statement in jquery Doesn't work - jqueryIs it possible to use animation or CSS transition in the flex-direction property? - cssAngular form validation, but without ? - javascriptImportError: cannot import name 'HTMLAwareEntitySubstitution' - python-3.5How to create WKWebView size in Swift 3 / iOS 10 - ios10NetBeans: Cannot start Tomcat ("The system cannot find the specified file") - javazip / unzip in R - rdebugging a Haskell application - debuggingAll Articles