I'm dealing with a large dataframe (~100,000x1000) that I eventually output using df.to_csv()
. All my inputs which I turn into this large dataframe come transposed relative to the output, so when building the large dataframe it ends transposed relative to the output. At the very end I transpose: df.T.to_csv()
. I know the return value of df.T
is the transposed
dataframe which leads to my question, by not saving the df.T
does it "help" my memory usage? Phrased differently, is df.T.to_csv()
better than dfT=df.T
and dfT.to_csv()
run separately? Aside from memory as there any advantages to one method over the other?
In summary which method is better and why?:
method 1:
df.T.to_csv()
method 2:
dfT=df.T
dfT.to_csv()