Hi
I am unsure why the following works in a jupyter notebook, but not in a python script that I am run from the Linux command line:
Any suggestions ?
I am unsure why the following works in a jupyter notebook, but not in a python script that I am run from the Linux command line:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#!/usr/bin/python3 import pandas as pd import numpy as np # SWAPPING COLUMNS dates = pd.date_range( '1/1/2019' ,periods = 12 ) df = pd.DataFrame(np.random.randn( 12 , 4 ),index = dates,columns = [ 'A' , 'B' , 'C' , 'D' ]) df_copy = df.copy() # assign, after converting to raw data df_copy.loc[: [ 'B' , 'A' ]] = df_copy[[ 'A' , 'B' ]].to_numpy() print (df_copy) |
logoslog