docstr: Tests that appending to existing table produces correct results when:
  if_replace='append'.
docstr_tok: ["Tests","that","appending","to","existing","table","produces","correct","results","when",":","if_replace='append","'","."]
code: def test_write_postgis_append_when_table_exists(
      self, engine_postgis, df_nybb
  ):
      """
      Tests that appending to existing table produces correct results when:
      if_replace='append'.
      """
      engine = engine_postgis
  
      table = "nybb"
  
      orig_rows, orig_cols = df_nybb.shape
      write_postgis(
          df_nybb, con=engine, name=table, if_exists="replace"
      )
      write_postgis(df_nybb, con=engine, name=table, if_exists="append")
      # Validate
      sql = text("SELECT * FROM {table};".format(table=table))
      df = read_postgis(sql, engine, geom_col="geometry")
      new_rows, new_cols = df.shape
  
      # There should be twice as many rows in the new table
      assert new_rows == orig_rows * 2, (
          "There should be {target} rows,"
          "found: {current}".format(
              target=orig_rows * 2, current=new_rows
          ),
      )
      # Number of columns should stay the same
      assert new_cols == orig_cols, (
          "There should be {target} columns,"
          "found: {current}".format(target=orig_cols, current=new_cols),
      )
  
imports: import os
  import warnings
  import pandas
  import geopandas
  from geopandas import GeoDataFrame, read_file, read_postgis
  import geopandas._compat
  from geopandas.io.sql import _get_conn, _write_postgis
  from geopandas.tests.util import create_postgis, create_spatialite, validate_boro_df
  import pytest
label_desc: Use image node_id 18 for calling the TestIO obj's underlying member method code with example usage: obj.test_write_postgis_append_when_table_exists(engine_postgis, df_nybb) without return types