In the code below, in line 4 I can transpose the dataframe, but in line 5, when I use to_csv, the new CSV file is created, it remains the original version and not the transposed one. What might have gone wrong?
import numpy as np
import pandas as pd
df = pd.read_csv('~/N.csv')
df2 = df.T
df2 = df.to_csv('~/N_transposed.csv')
Thank you!