Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
I'm also facing the same issue. any suggestions?
E.g. Copy a string column that only contains numbers, that the copied column is also of type string and not casted to integer or float?
For the time being, I've converted the field to string and concatenated required number of values (omitting .0 ) in the python recipe and loaded to output dataset.
I'm also facing this issue in a python recipe. Although the column is typed as string (Object) and I defined the output schema to be string: Text, after running the recipe this column gets converted into numbers.
The business issue here is that this column contains zero-padded values which we need to keep.
So how can one define and keep the output format as defined?
Welcome @Wido !
I have the same business issue with those zero-padded values, but have not encountered problems with keeping them intact. Different is that i don't (yet) use python recipes when handling those, so hopefully someone else can help you with that. For a visual-oriented solution there is an example below.
Example : copying a zero-padded value to a new column . I use a visual prepare step, the formula-option and simply state strval("column_name") , the value is copies 'as is' to the new column including preceeding zero's.. When using val("column_name"), numval("column_name") or just column_name the padding gets stripped.
As my coworkers have an Excel-mania i do add a dummy-prefixletter to those values before exporting data out of dataiku, to ensure that excel sees those values as a stringvalue and won't start stripping them.
Iโve not tried this. However, I was thinking about your export to excel question below. Rather than using a dummy letter have you thought of pretending a single quote. โ to the 0 prefixed number. Something like:
Postal code |
โ08904 |
โ07204 |
MS Excel sees the single quote as a prefix that means that the following is text and should not be seen as a number. I donโt know if this will work from within Dataiku. But it might be worth a try.
Hi TOM, ' will remain in the cells in EXCEL, click each cell then enter, it will recognize it as TEXT, then remove '. Howeve, not possible to click and enter in each cell.
Your suggestion is great, surely preferable over what i do with those prefixes now @tgb417 Tom, i didn't know excel could be forced in this way. Sadly i can't use it : this prefixletter is a fixed and longstanding procedural thing to ensure everybody involved has a crystal clear picture of what a certain value represents. A dirty solution for a "between display and chair"-challenge so to speak.
Thanks for your thoughts and suggestions. I have found a solution, that works for me.
The template code for python recipe is not very helping here. The input and output schemas get overwritten using that code. What you need to do:
input_df = dataset.get_dataframe(infer_with_pandas=False)
By default pandas infers the schema and overwrites what you have defined as input.
For writing the dataframe the template suggests to use
new_dataset.write_with_schema(my_dataframe)
However the following will use the schema as defined:
new_dataset.write_dataframe(output_df)
To be honest the documentation is very poor at this point. A lot if talk around the topic but no clear API specification. But it solves my issue now. Hopefully it can help others as well.
Could u please explain how you did that?, i have the error message. Thanks
test = dataiku.Dataset("test")
test.write_dataframe(test_df)
Exception: An error occurred during dataset write (d2nJvJdtaK): RuntimeException: Forbidden state transition : ERROR -> STREAMING
I've run into the same problem V11.0.3.
The dku.write_dataframe()
Is still not keeping my variables stable.
Right now I'm finding my variables changed back to strings. And then in a subsequent step when I try to do a join my types don't match.
The underlying data source is a PostgreSQL database.
I've discovered a similar problem.
I'm using the API connect plugin run by a scenario. Sometime the plugin can not connect to the remote API. When this happens from time to time my column with the integer API response code is converted to Float rather than the typical Int. Causing the Recipe to fail. Not fully clear why this is occurring. But this is another example where uncontrolled "duck typing" is causing problems.
cc: @AlexB