-1

I have an excel spreadsheet with multiple columns. I want the sheet to be filtered based on a row called 'Timing' And the value I want to filter for is called 'C10'. What is the code to write that will filter the Timing column for C10?

I tried

df_filtered=df[df['Timing] == 'C10'

The code did not work

wjandrea
  • 28,235
  • 9
  • 60
  • 81
auston215
  • 7
  • 3
  • 1
    You have a typo? `df[df['Timing'] == 'C10']` (missing ending `]`) – Corralien Feb 17 '22 at 02:59
  • Sorry, yes I have it as you posted and it does not work. – auston215 Feb 17 '22 at 03:00
  • Update your post with the output of `print(df.head())` please – Corralien Feb 17 '22 at 03:01
  • 1
    There's another typo: `'Timing` is missing a closing single-quote. – wjandrea Feb 17 '22 at 03:02
  • For debugging help, you need to make a [mre] including complete but minimal code, example input (enough data to demonstrate the issue), expected output, and the [full error message with traceback](https://meta.stackoverflow.com/q/359146/4518341). See also [How to make good reproducible pandas examples](/q/20109391/4518341). – wjandrea Feb 17 '22 at 03:04

1 Answers1

0

If you have no typo, try to remove leading and trailing whitespace on your column first:

df_filtered = df[df['Timing'].str.strip() == 'C10']
Corralien
  • 109,409
  • 8
  • 28
  • 52