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

DataFrame in Script and Flow Showing Incorrect Column Order

I created a dataframe firstly with these 3 columns in this order: ["ID", "Amount", "Status"]
Then I reorder the column to ["Status", "ID", "Amount"]

However when shown in Windmill, it doesn't get reordered.

This is just a simplification of my code, in reality I'm working with more complex column management, but this issue makes me cannot proceed.

Here is the full code
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=';')
    df2 = df[['Status', 'ID', 'Amount']]

    # Debugging: Print DataFrame information
    print("DataFrame columns:", df2.columns)
    print("DataFrame head:\n", df2.head())
    
    # Return the DataFrame
    return df2.to_dict('records') 
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=';')
    df2 = df[['Status', 'ID', 'Amount']]

    # Debugging: Print DataFrame information
    print("DataFrame columns:", df2.columns)
    print("DataFrame head:\n", df2.head())
    
    # Return the DataFrame
    return df2.to_dict('records') 
image.png
WindmillJoin
3,362Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Recent Announcements
henri-c

Weekly kenote to tell you about our latest updates https://discord.com/channels/930051556043276338/1278977038430240813 https://youtube.com/live/2dGd9TdT8xs?feature=share

henri-c · 4d ago

Pyra

### HTTP tracing (EE) Capture HTTP requests made by job scripts as observability spans Features: - View HTTP request traces (method, URL, status, timing) in the job details UI - Auto-instrumentation for Native TypeScript, MITM proxy for other languages - Integrates with external OpenTelemetry collectors changelog: https://www.windmill.dev/changelog/http-tracing docs: https://www.windmill.dev/docs/advanced/instance_settings#http-tracing Additionally jobs memory metrics are now fully OSS!

Pyra · 2w ago

henri-c

First keynote of the year here https://discord.com/channels/930051556043276338/1278977038430240813 🙂

henri-c · 4w ago

Similar Threads

[Solved] DataFrame in Script and Flow Showing Incorrect Headers
brian_gtbBbrian_gtb / help
2y ago
Triggering a script or flow from AgGrid Table column definition
emmortsEemmorts / help
3y ago
Flow integration not showing inputs
guillemGguillem / help
9mo ago
Using perpetual script to trigger flow
TwoToTooTTwoToToo / help
5mo ago