0
$\begingroup$

I know how to separate numerical and categorical data as follows:

num_data = [cname for cname in df.columns if df[cname].dtypes == 'object']
cat_data = [cname for cname in df.columns if df[cname].dtypes in ['int64', 'float64']]

Now I want to separate my numerical variables into discrete and continuous. How do I do that?

$\endgroup$
5
  • $\begingroup$ How do you define discrete and continuous variables? // Since you have discrete observations, there is an argument that all of your variables are discrete. $\endgroup$
    – Dave
    Jan 8 at 7:25
  • $\begingroup$ Discrete as in 1.0, 2.0, 5.0, 111.0 and so on. Continuous as in 1.1, 1.199, 444.34 and so on. $\endgroup$
    – spectre
    Jan 8 at 9:49
  • $\begingroup$ Wouldn‘t be a int column „discrete“ and „continuous“ float? $\endgroup$
    – Peter
    Jan 8 at 11:24
  • $\begingroup$ In my case, 1.0 is a discrete variable and float at the same time. $\endgroup$
    – spectre
    Jan 8 at 11:36
  • $\begingroup$ How to test if my data is discrete or continuous? $\endgroup$ Jan 8 at 12:04

Your Answer

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

Browse other questions tagged or ask your own question.