return global dataframe from functin code example
Example 1: how to set pandas dataframe as global
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()
Example 2: how to set pandas dataframe as global
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)