Skip to content

Conversation

@ColinLeeo
Copy link
Contributor

@ColinLeeo ColinLeeo commented Jan 14, 2026

def dataframe_to_tsfile(dataframe: pd.DataFrame,
                        file_path: str,
                        table_name: Optional[str] = None,
                        time_column: Optional[str] = None,
                        tag_column: Optional[list[str]] = None,
                        ):
    """
    Write a pandas DataFrame to a TsFile by inferring the table schema from the DataFrame.
    This function automatically infers the table schema based on the DataFrame's column
    names and data types, then writes the data to a TsFile.
    Parameters
    ----------
    dataframe : pd.DataFrame
        The pandas DataFrame to write to TsFile.
        - If a 'time' column (case-insensitive) exists, it will be used as the time column.
        - Otherwise, the DataFrame index will be used as timestamps.
        - All other columns will be treated as data columns.
    file_path : str
        Path to the TsFile to write. Will be created if it doesn't exist.
    table_name : Optional[str], default None
        Name of the table. If None, defaults to "table".
    time_column : Optional[str], default None
        Name of the time column. If None, will look for a column named 'time' (case-insensitive),
        or use the DataFrame index if no 'time' column is found.
    tag_column : Optional[list[str]], default None
        List of column names to be treated as TAG columns. All other columns will be FIELD columns.
        If None, all columns are treated as FIELD columns.
    Returns
    -------
    None
    Raises
    ------
    ValueError
        If the DataFrame is empty or has no data columns.
    """

@ColinLeeo ColinLeeo force-pushed the support_dataframe_to_tsfile branch from d6aa3e1 to 8c93df1 Compare January 14, 2026 14:37
@codecov-commenter
Copy link

codecov-commenter commented Jan 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.87%. Comparing base (420f5c0) to head (46de126).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #706      +/-   ##
===========================================
- Coverage    61.88%   61.87%   -0.01%     
===========================================
  Files          709      709              
  Lines        40231    40237       +6     
  Branches      5655     5656       +1     
===========================================
+ Hits         24895    24897       +2     
- Misses       14638    14642       +4     
  Partials       698      698              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ColinLeeo ColinLeeo force-pushed the support_dataframe_to_tsfile branch from 8c93df1 to 46de126 Compare January 14, 2026 15:09
@ColinLeeo ColinLeeo requested a review from jt2594838 January 14, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants