The researchpy's summary_cont() page there is an example and it is given as;
import numpy, pandas, researchpy
numpy.random.seed(12345678)
df = pandas.DataFrame(numpy.random.randint(10, size= (100, 2)),
columns= ['healthy', 'non-healthy'])
df['tx'] = ""
df['tx'].iloc[0:50] = "Placebo"
df['tx'].iloc[50:101] = "Experimental"
df['dose'] = ""
df['dose'].iloc[0:26] = "10 mg"
df['dose'].iloc[26:51] = "25 mg"
df['dose'].iloc[51:76] = "10 mg"
df['dose'].iloc[76:101] = "25 mg"
produces warning
summury_cont.py:8: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
df['tx'].iloc[0:50] = "Placebo"
This asks to see this page
Converting into this
df.loc[:, ('tx')].iloc[0:50] = "Placebo"
It still produces the same warning. What is the correct way of this?