mirror of
				https://github.com/fjosw/pyerrors.git
				synced 2025-11-04 01:25:46 +01:00 
			
		
		
		
	fix: pandas.to_sql does not write an index to the db anymore, docs
extended, test added.
This commit is contained in:
		
					parent
					
						
							
								504a8f3486
							
						
					
				
			
			
				commit
				
					
						845b4e60ac
					
				
			
		
					 2 changed files with 13 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -51,3 +51,13 @@ def test_gz_serialization():
 | 
			
		|||
        ser = pe.input.pandas._serialize_df(my_df, gz=gz)
 | 
			
		||||
        deser = pe.input.pandas._deserialize_df(ser)
 | 
			
		||||
        np.all(my_df == deser)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_sql(tmp_path):
 | 
			
		||||
    my_list = [{"Label": i, "Obs": pe.pseudo_Obs(5 * np.exp(-0.2 * i), 0.01, "test_ensemble", 20)} for i in range(150)]
 | 
			
		||||
    pe_df = pd.DataFrame(my_list)
 | 
			
		||||
    my_db = (tmp_path / "test_db.sqlite").as_posix()
 | 
			
		||||
    pe.input.pandas.to_sql(pe_df, "My_table", my_db)
 | 
			
		||||
    for auto_gamma in [False, True]:
 | 
			
		||||
        re_df = pe.input.pandas.read_sql_query("SELECT * from My_table", my_db, auto_gamma=auto_gamma)
 | 
			
		||||
        assert np.all(re_df == pe_df)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue