WindmillWWindmill
Powered by
brian_gtbB
Windmill•2y ago•
3 replies
brian_gtb

[Solved] DataFrame in Script and Flow Showing Incorrect Headers

I always got confused why my DataFrame header is not correct. You may see this sample code, I printed the logs also to see what Column Header it should have vs what being shown in Windmill. Please see the image. Let me know if the issue is on my side or Windmill's.

I expect the column headers: ID, Amount, Status
What being shown in Windmill: col0, col1, col2

Thanks.

import pandas as pd
from typing import Any
import csv
import io

def main() -> Any:
    # Create a dummy CSV data string with 3 columns
    csv_data = """ID;Amount;Status
    abc123;1000;completed
    def456;2000;pending
    ghi789;3000;failed"""

    # Use StringIO to treat the string as a file object
    csv_file_like_object = io.StringIO(csv_data)

    # Read the CSV data into a DataFrame directly
    df = pd.read_csv(csv_file_like_object, delimiter=';')

    # Debugging: Print DataFrame information
    print("DataFrame columns:", df.columns)
    print("DataFrame head:\n", df.head())
    
    # Return the DataFrame
    return df
import pandas as pd
from typing import Any
import csv
import io

def main() -> Any:
    # Create a dummy CSV data string with 3 columns
    csv_data = """ID;Amount;Status
    abc123;1000;completed
    def456;2000;pending
    ghi789;3000;failed"""

    # Use StringIO to treat the string as a file object
    csv_file_like_object = io.StringIO(csv_data)

    # Read the CSV data into a DataFrame directly
    df = pd.read_csv(csv_file_like_object, delimiter=';')

    # Debugging: Print DataFrame information
    print("DataFrame columns:", df.columns)
    print("DataFrame head:\n", df.head())
    
    # Return the DataFrame
    return df
image.png
WindmillJoin
3,388Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?
Recent Announcements
henri-c

We're live here https://discord.com/channels/930051556043276338/1278977038430240813

henri-c · 2d ago

rubenf

Infrastructure as code

rubenf · 3w ago

rubenf

As we're preparing for a new Windmill sandbox SDK, we took the opportunity **to open-source NSJAIL sandboxing** and make it available in CE and easier to set. In 1.634.0, just set nsjail to benefit from the tightest security and isolation per job. It's constraining so no need to use it unless you need but now you won't be restricted in security for CE if you need to.

rubenf · 4w ago

Similar Threads

DataFrame in Script and Flow Showing Incorrect Column Order
brian_gtbBbrian_gtb / help
2y ago
Flow integration not showing inputs
guillemGguillem / help
10mo ago
Using perpetual script to trigger flow
TwoToTooTTwoToToo / help
6mo ago
Running a script fails when executed in a flow
BravoBBravo / help
16mo ago