Accessing a pandas.DataFrame column name with a '.' in it Accessing a pandas.DataFrame column name with a '.' in it pandas pandas

Accessing a pandas.DataFrame column name with a '.' in it


Use []:

df['Project.Fwd_Primer']

Sample:

import pandas as pddf = pd.DataFrame({'Project.Fwd_Primer': {0: '1', 1: '2'}})print (df)    Project.Fwd_Primer0                  11                  2  print (df['Project.Fwd_Primer'])0    11    2Name: Project.Fwd_Primer, dtype: object

EDIT:

You can also check attribute access in docs:

Warning

You can use this access only if the index element is a valid python identifier, e.g. s.1 is not allowed. See here for an explanation of valid identifiers.

The attribute will not be available if it conflicts with an existing method name, e.g. s.min is not allowed.

Similarly, the attribute will not be available if it conflicts with any of the following list: index, major_axis, minor_axis, items, labels.

In any of these cases, standard indexing will still work, e.g. s['1'], s['min'], and s['index'] will access the corresponding element or column.

The Series/Panel accesses are available starting in 0.13.0.