-3

How to get output of a column of a DataFrame? Suppose, I have a DataFrame DF which has columns: name, marks, phone in it.

How to het one of the column in python?

  • 1
    check [here](https://stackoverflow.com/questions/11361985/output-data-from-all-columns-in-a-dataframe-in-pandas) – Kofi Jan 15 '22 at 10:09
  • Thanks, I am just started learning python. Thanks for helping. – recent updates. Jan 15 '22 at 10:11
  • Does this answer your question? [How do I select rows from a DataFrame based on column values?](https://stackoverflow.com/questions/17071871/how-do-i-select-rows-from-a-dataframe-based-on-column-values) – rikyeah Jan 15 '22 at 10:35

2 Answers2

-1

You can get the output of any columns by:

For Name:

DF["name"]

or you can use:

DF.name

Like this, you can insert the name of any column in place of "name".

Akash Kumar
  • 540
  • 2
  • 4
  • 15
-1

you can select one column, e.g. DF["name"] or DF.name and multiple columns by passing a list, e.g. DF[["name", "marks"]].

Be careful with the DF.name notation as it doesn't work when the column name has special characters, e.g. whitespaces.

Florian
  • 1
  • 1