question

Upvotes
Accepted
3 0 1 3

How to make a list from the column headers?

Hi I am working on a project and would like to know if it's possible to extract the column headers, excluding the first cell, from rd.get_history result and put it inside a list. May I ask for guidance on how to do it?


As a sample, I am using this code



import refinitiv.data as rd

rd.open_session()

import pandas as pd

df = rd.get_history(universe = "LSEG.L", interval = "1D"))


df

I'd like to make a list from the boxed headers, the RIC <LSEG.L> is excluded.


eikon-data-api#technologyrefinitiv-data-platform
1727246033202.png (180.2 KiB)
1727246061292.png (193.0 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Upvotes
Accepted
15.5k 33 5 10

Hi @johnnavi.quinones ,

To get columns name, the code below can be used

df.columns

and it can be convert as a Python list with

col_list = df.columns.to_list()
col_list

1727251912250.png


1727251912250.png (29.4 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thanks!!!!

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.