add a row to a dataframe using streamlit

Solution

You MUST first check the type of ticker_add.

type(ticker_add)

Adding new row to a dataframe

  1. Assuming your ticker_add is a dictionary with the column names of the dataframe df as the keys, you can do this:

    df.append(pd.DataFrame(ticker_add))
    
  2. Assuming it is a single non-array-like input, you can do this:

    # adds a new row for a single column ("Ticker") dataframe
    df = df.append({'Ticker': ticker_add}, ignore_index=True)
    

References

  1. Add one row to pandas DataFrame
  2. https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.append.html

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top