Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 480

pandas.DataFrame.apply with row names and coulmn names as arguments

$
0
0

Is there a way to use the apply function and pass the name of the specific row and column of each cell as arguments? In other words, I want to perform an operation to the cartesian product of two sets. Example:

countries = ["Germany", "France", "Belgium"]years = [2030, 2040, 2050]df = pandas.DataFrame(columns = countries, index = years)def myFunc(countryname, year):   return countryname + str(year)df.apply(myFunc) # I don't know how to pass the arguments

Maybe there is another way to do this without using nested for-loops?


Viewing all articles
Browse latest Browse all 480

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>