question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Accommodate DataFrames with numeric column names

See original GitHub issue

As demonstrated in the example from this stack overflow response, when converting a NumPy array into a Dataframe, the column labels are initially numeric. When trying to index by these column labels, I realized the backend DataFrame indexing is using the attribute method, df.column_label, and not the df[column_label] method. The current method supports less variation in column label in that it only supports valid python identifiers, e.g., column labels cannot be purely numeric. This Pandas’ doc page has more details. If possible, changing to the [ ] method (or __getitem__ method) would allow for a wider range of inputs, thereby simplifying the user experience.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jbednarcommented, Feb 17, 2017

[A PR would hurry this process along, by the way! 😃]

0reactions
StevenCHowellcommented, Feb 19, 2017

I tested the code as it is (without the change made by pr #285), and it did take column names that would not work with the df.col_name syntax, e.g., df['x values']. It seems the real issue was it did not take numeric column names, which #285 fixes (small change as it is).

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to get numeric column names in pandas dataframe
Use select_dtypes with np.number for select all numeric columns: df = pd.DataFrame({'A':list('abcdef'), 'B':[4.5,5,4,5,5,4], 'C':[7.4,8,9,4 ...
Read more >
Essential basic functionality — pandas 1.5.2 documentation
Passing a dictionary of column names to a scalar or a list of scalars, to DataFrame.agg allows you to customize which functions are...
Read more >
Solved Read in the dataset into a dataframe. Keep only the
Question: Read in the dataset into a dataframe. Keep only the belowcolumns. Make sure the numeric columns are in the correct datatype.
Read more >
Simple guide to combine dataframes using pandas
As we can see above, we can initiate column names using column keyword inside DataFrame method with syntax as pd.DataFrame(values, column).
Read more >
Extract or Replace Parts of a Data Frame - R
i, j, elements to extract or replace. i, j are numeric or character or, ... Similarly, column names will be transformed (if columns...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found