# How to order the data with respect to data type

I am having large data set (82 variables) Is there any way to arrange data such a way that I have to get all numerical variables firstly then categorical variables so that I can run hypothesis testing or exploratory data analysis(eda) by having loop.

If not is there any way to do eda in simpler manner because I can't check the correlation or chi.square test for each variable

Let your data frame be df. First get the numeric columns:

num_col = df.select_dtypes('number').columns


Then get the remaining columns.

non_num_col = set(df.columns) - set(df.select_dtypes('number').columns)


Merge as required.

df = pd.concat([df[num_col], df[list(non_num_col)]], axis=1)


The columns are now in the desired sequence.

• Thanks for the answer – user12490809 Dec 26 '19 at 7:01
• If it worked. Please upvote and Mark as resolved. – Ansh Dec 26 '19 at 11:48