my kernel dies when I try to change a dataframe with data that I get using an sql query.
I reduced the amount of data, increased my RAM and commented out code that consistently crashed the kernel.
python
import pandas as pd
import sqlalchemy
sql_str = """some sql query limit 100"""
df = pd.read_sql(sql_str, engine)
list=[
'1st name','2nd name']
for i in range(0,len(list)):
df.columns.values[i]=list[i]
#naming the columns of my df
df=df[df["tradedate"]<'01-01-2017']
#this is a line of code that sometimes crashes the kernel
df['strike']=pd.to_numeric(df["strike"],errors='coerce')
#another one
I expect a clean dataframe with which I can work, instead the kernel dies and I get a windows error.
I would be incredibly thankful if somebody could help me here!
Try to use chunksize parameter:
df = pd.read_sql(sql_str, engine, chunksize=20) #try different values
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With