How To Set Pandas Dataframe As Global Code Example

Snippet 1

  import pandas as pd

data = pd.DataFrame({'A' : [1, 2, 3, 4],
                     'B' : [1,2,3,4]})

def test(data):
   data =  data + 1
   return data

data = test(data)
 

Snippet 2

  import pandas as pd

data = pd.DataFrame({'A' : [1, 2, 3, 4],
                     'B' : [1,2,3,4]})
def test():
    global data
    data =  data + 1

test()
 

Copyright © Code Fetcher 2020

 

 

Leave a comment

Your email address will not be published. Required fields are marked *