In Python 3 and Pandas I have this dataframe:
te_cnpjs.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 1255 entries, 0 to 5663
Data columns (total 13 columns):
DATA_LS 856 non-null object
DATA_INCLUS 789 non-null object
Proprietario 1255 non-null object
Nome_propriedade 1255 non-null object
Municipio 1253 non-null object
Estado 1253 non-null object
CNPJ_CPF_CEI 1255 non-null object
CNPJ_CPF_CEI_limpo 1255 non-null float64
Trab_Envolv 995 non-null float64
Ramo_atividade 540 non-null object
Localizacao 527 non-null object
Cod_ativ 563 non-null object
Tipo_lista 1255 non-null object
dtypes: float64(2), object(11)
memory usage: 137.3+ KB
The column "CNPJ_CPF_CEI_limpo" has codes of 13 or 14 digits: "6158959000136", "78141843000103", "4773160000000", "78231701000986"...
I created a new column from the column "CNPJ_CPF_CEI_limpo", but only with its 8 first numbers
But I received warning messages: A value is trying to be set on a copy of a slice from a DataFrame
First I turned the "CNPJ_CPF_CEI_limpo" column into integer:
te_cnpjs['CNPJ_CPF_CEI_limpo'] = te_cnpjs.CNPJ_CPF_CEI_limpo.astype('int64')
/home/reinaldo/Documentos/Code/RB/te/lib/python3.6/site-packages/ipykernel_launcher.py:1: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
"""Entry point for launching an IPython kernel.
Then I created the new column, "CNPJ_raiz", with only the first eight numbers:
te_cnpjs['CNPJ_raiz'] = te_cnpjs['CNPJ_CPF_CEI_limpo'].astype(str).str[:8]
/home/reinaldo/Documentos/Code/RB/te/lib/python3.6/site-packages/ipykernel_launcher.py:1: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
"""Entry point for launching an IPython kernel.
The result was expected, it worked. But I want to understand if the warning message can mean if what I'm doing has some risk of error