how do I specify the column numbers in a dataframe code example

Example 1: convert column to numeric pandas

# convert all columns of DataFrame
df = df.apply(pd.to_numeric) # convert all columns of DataFrame

# convert just columns "a" and "b"
df[["a", "b"]] = df[["a", "b"]].apply(pd.to_numeric)

Example 2: get column number in dataframe pandas

# PANDAS: get column number from colomn name
dataframe.columns.get_loc("<col_name>")

Example 3: python count variable and put the count in a column of data frame

df['freq'] = df.groupby('myvar')['myvar'].transform('count')