Fix dtype inference and session cookie handling#1237
Fix dtype inference and session cookie handling#1237Cubewise-Ronan wants to merge 2 commits intocubewise-code:masterfrom
Conversation
| # make sure all element names are strings and values column is derived from data | ||
| if 'dtype' not in kwargs: | ||
| kwargs['dtype'] = {'Value': None, **{col: str for col in range(999)}} | ||
| kwargs['dtype'] = {'Value': str, **{col: str for col in range(999)}} |
There was a problem hiding this comment.
We don't want the value column to be str in all cases, do we?
If we set it to None instead, it will be derived depending on the data at hand
There was a problem hiding this comment.
Actually, that was the issue I was running into — setting 'Value': None causes pandas to infer the dtype, and in some cases like "2025" (which is an attribute value for an element and should be a string), it gets coerced to 2025.0 if other rows are missing values or inconsistent.
There was a problem hiding this comment.
I understand. But we can't enforce str as the column type for the value column. Most retrieved cube data will be numeric!
In the edge cases where you load data from attribute cubes it would be easier to pass dtype=str to the execute_mdx_dataframe function.
| for cookie in self._s.cookies: | ||
| if cookie.name == 'TM1SessionId': | ||
| session_id = cookie.value | ||
| # break # Use the first match |
There was a problem hiding this comment.
Maybe this is an obsolete comment or did you want to break after the first match?
strinpd.read_csvto avoid misinterpreting values like '2025' as floats.