0
$\begingroup$

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

$\endgroup$

1 Answer 1

0
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ Thanks for the answer $\endgroup$ Dec 26, 2019 at 7:01
  • $\begingroup$ If it worked. Please upvote and Mark as resolved. $\endgroup$
    – Ansh
    Dec 26, 2019 at 11:48
  • $\begingroup$ Next time please format your answer properly. $\endgroup$
    – Peter
    Jan 1, 2020 at 22:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.