Python Tile

Ashleigh
Ashleigh Florida 🟒

Tring to split the values in a column into multiple rows using explode and I keep getting an error. I am not too familiar with the python tiles...

The value in my row will be "A<br>B" and I want them to appear as two separate rows, one with A and one with B.

Getting error:

"00:00:01.817 domomagic: Version 0.3
00:00:01.819 Traceback (most recent call last):
00:00:01.819   File "<stdin>", line 10, in <module>
00:00:01.819   File "/opt/conda/envs/legacy/lib/python3.7/site-packages/pandas/core/generic.py", line 5067, in __getattr__
00:00:01.819     return object.__getattribute__(self, name)
00:00:01.820 AttributeError: 'DataFrame' object has no attribute 'explode'


My code is:

# Import the domomagic package into the scriptΒ 

from domomagic import *

import pandas as pd


# read data from inputs into a data frame

input1 = read_dataframe('DataFlows')


# write your script here

df = pd.DataFrame(input1)

df.explode('input_datasources')

output = pd.DataFrame(df)


# write a data frame so it's available to the next action

write_dataframe(output)

Best Answers

  • jaeW_at_Onyx
    jaeW_at_Onyx Budapest / Portland, OR 🟀
    Answer βœ“

    send a support ticket. looks like it's an old build of Pandas?


    Tutorial on how to do the thing in MySQL


    To do it in MySQL 2.0

    1) count the number of times <br> occurs. use a formula tile.

    2) duplicate each row the number of times <br> occurs + 1 (use the countdown table described here, https://www.youtube.com/watch?v=cOiT3FjQ7K8&t=667s

    3) use text processing to find the n'th value before or after the <br>

    Jae Wilson
    Check out my πŸŽ₯ Domo Training YouTube Channel πŸ‘¨β€πŸ’»

    **Say "Thanks" by clicking the ❀️ in the post that helped you.
    **Please mark the post that solves your problem by clicking on "Accept as Solution"
  • GrantSmith
    GrantSmith Indiana πŸ₯·
    edited March 2021 Answer βœ“

    Hi @Ashleigh

    explode was introduced with pandas 0.25.0. It definitely looks like Domo has an older version of pandas. You can confirm the version they have installed using

    pd.__version__
    

    I'm in agreement with @jaeW_at_Onyx . Send a ticket to support. They might be able to configure a custom environment for you with the proper package versions you might need.



    **Was this post helpful? Click Agree or Like below**

    **Did this solve your problem? Accept it as a solution!**

Answers