OpenSourceEconomics / skillmodels

MIT License
11 stars 5 forks source link

Avoid mixing of strings and integers in index #30

Closed hmgaudecker closed 4 years ago

hmgaudecker commented 5 years ago

e.g., I have some stuff where start_params_helpers() produces

category,period,name1,
x,0,0,

among other things. Note the 0 integer for name1. The problem is that if you save this as csv, change the start values, and read it back into Pandas, read_csv will convert the integer into a string and fit() will complain with:

ValueError: Index of start parameters has to be either self.params_index or the index of free parameters from start_params_helpers.

Not the worst thing in the world, but a bit annoying...

hmgaudecker commented 5 years ago

@janosg: This happens for the x, p - parameters. In the broader picture, would it not be more useful to use only name1 (x) and both name1 / name2 (p) ?

janosg commented 5 years ago

I remember that issue too. Probably the easiest solution is to add a load_params method. I also agree with that we should use name1 and name2 for p.

hmgaudecker commented 5 years ago

I think this should be fixed at the point of exporting the parameters -- or is there a specific reason why it should be 0 for the name as opposed to the empty string?

janosg commented 5 years ago

The first 0 is for the period. The second one enumerates the mixture elements. The period is redundant because x is only estimated in period 0. I guess this is a case of practicality beats purity and we should omit the first zero.

hmgaudecker commented 5 years ago

Ah, okay. I would vote for purity and being really explicit then.

mixture_0, mixture_1, ...

janosg commented 4 years ago

A related problem is that empty strings get replaced by np.nan when read from csv. I will replace all empty strings in the index by "-".