Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any difference between using Dataframe.columns and Dataframe.keys() to obtain the column names?

For the sake of curiosity is there any practical difference between getting the column names of a DataFrame (let's say df) by using df.columns or df.keys()?

I've checked the outs by type and it seems to be exactly the same. Am I missing something or these two methods are just as redundant as it seems? Is one more appropriate to use than the other?

Thanks.

like image 875
Chicrala Avatar asked Oct 22 '25 17:10

Chicrala


1 Answers

one difference I noticed That you can Use .keys() with Series but You can not use .columns with Series .

like image 61
hesham ahmed Avatar answered Oct 24 '25 09:10

hesham ahmed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!