Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Order of variables when DF is fed to fit with CFA: either document or actually use the column names?

Open
#146 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Start with ConfirmatoryFactorAnalyzer.fit and ModelSpecificationParser.parse_model_specification_from_dict, then reproduce the documentation example using a dataframe whose columns are not in model_spec.variable_names order. Done means the column-order behavior is explicitly documented and the example reflects it, or dataframe column names are honored consistently by the CFA path.

Written by the indexing model from the issue text.

Description

As it is currently implemented, it appears that the fit function of confirmatory_factor_analyzer assumes that you'll give it an arraylike object or a dataframe. But it doesn't use the column names in the dataframe instead assuming (with no documentation?) that the order of the columns in the dataframe will be whatever the model_spec.variable_names ends up being. Am I correct in this?

This causes significant problems because the example in the documentation will not work if you're assuming as I did that confirmatory_factor_analyzer.fit() actually uses the column names if fed a data frame? For example with the current example, it only works because the model spec expects the columns to be in the order V1,V2,...,V8 and that dataframe happens to present them in that order.

But you cannot easily guess what parse_model_specification_from_dict will decide the variable_names object should be. So currently in order to make it work I'm having to do the following:

model_spec = ModelSpecificationParser.parse_model_specification_from_dict(df, model_dict)

# this is the key line that seems to be required but isn't documented anywhere
# it reorders the df to match the order of the variable_names that the model parser has decided it would like to receive them in
df = df[model_spec.variable_names]

cfa = ConfirmatoryFactorAnalyzer(model_spec, disp=False)
cfa.fit(df)

Thank you to anyone who can help confirm my thinking. If I'm correct here, then maybe you need to decide to either document this behavior clearly or decide to make the whole CFA functionality column-name aware instead of assuming to naively convert everything it is fed into an array with X.values.

Dominant language
Python
Stars
6
Forks
1
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from EducationalTestingService/factor_analyzer

All issues in EducationalTestingService/factor_analyzer

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.