0

I'm working with a pretty large dataframe. Most of the columns are being read just fine but there's a specific column called 'Delivered?' where each cell is either going to have the text "Yes", "No", or "Partially". But when I print that column every item shows as NaN.

Here's the code I have now: file = pd.read_excel(file_path, sheet_name="April") print(file['Delivered?'])

I've tried change the 'dtype' and adding 'converters' and changing the column from a general type to a text type but nothing worked. When I run the above code this is what I get:

0    NaN
1    NaN
2    NaN
3    NaN
4    NaN
5    NaN
6    NaN
7    NaN
8    NaN
9    NaN
10   NaN
.
.
.


Name: Delivered?, dtype: float64
Andrej Kesely
  • 168,389
  • 15
  • 48
  • 91
  • 1
    Do other columns return the correct values? – Captain Caveman Apr 05 '23 at 16:16
  • 'Name: Delivered?, dtype: float64' is your problem you need to set up the reader to specifically look for a type that matches the column. You are looking for numbers, not a string. – Paul Brennan Apr 05 '23 at 17:06
  • 1
    https://stackoverflow.com/questions/32591466/python-pandas-how-to-specify-data-types-when-reading-an-excel-file will answer your problems – Paul Brennan Apr 05 '23 at 17:07
  • @PaulBrennan I've tried converting to str but now it says the dtype is 'object' but still returns NaN. if I use type() it says . Do I just need to implement some kind of __str__ method? – koliosis-work Apr 12 '23 at 14:48

0 Answers0