-1

When I do train.info() to see overall data types it shows that there are strings "objects" in my data. How do I see what it is by locating the data?

For example, when I do train.info() it shows that 6 columns contain objects. I believe the string is 'asia'. How can I print out all the string objects that are inside my dataframe?

<class 'pandas.core.frame.DataFrame'> RangeIndex: 40000 entries, 0 to 39999 Data columns (total 101 columns): x0 39989 non-null float64 x1 39990 non-null float64 x2 39992 non-null float64 x3 39991 non-null float64 x4 39992 non-null float64 x5 39994 non-null float64 x6 39990 non-null float64 x7 39991 non-null float64 x8 39994 non-null float64 x9 39993 non-null float64 x10 39991 non-null float64 x11 39993 non-null float64 x12 39989 non-null float64 x13 39986 non-null float64 x14 39997 non-null float64 x15 39996 non-null float64 x16 39993 non-null float64 x17 39988 non-null float64 x18 39986 non-null float64 x19 39992 non-null float64 x20 39995 non-null float64 x21 39987 non-null float64 x22 39994 non-null float64 x23 39992 non-null float64 x24 39986 non-null float64 x25 39989 non-null float64 x26 39991 non-null float64 x27 39992 non-null float64 x28 39989 non-null float64 x29 39995 non-null float64 x30 39996 non-null float64 x31 39992 non-null float64 x32 39996 non-null float64 x33 39990 non-null float64 x34 39993 non-null object x35 39987 non-null object x36 39993 non-null float64 x37 39996 non-null float64 x38 39994 non-null float64 x39 39991 non-null float64 x40 39994 non-null float64 x41 39996 non-null object x42 39988 non-null float64 x43 39998 non-null float64 x44 39998 non-null float64 x45 39995 non-null object x46 39993 non-null float64 x47 39996 non-null float64 x48 39990 non-null float64 x49 39997 non-null float64 x50 39993 non-null float64 x51 39989 non-null float64 x52 39992 non-null float64 x53 39994 non-null float64 x54 39995 non-null float64 x55 39989 non-null float64 x56 39989 non-null float64 x57 39992 non-null float64 x58 39991 non-null float64 x59 39990 non-null float64 x60 39988 non-null float64 x61 39993 non-null float64 x62 39987 non-null float64 x63 39986 non-null float64 x64 39995 non-null float64 x65 39988 non-null float64 x66 39991 non-null float64 x67 39991 non-null float64 x68 39992 non-null object x69 39987 non-null float64 x70 39995 non-null float64 x71 39995 non-null float64 x72 39992 non-null float64 x73 39988 non-null float64 x74 39993 non-null float64 x75 39990 non-null float64 x76 39990 non-null float64 x77 39991 non-null float64 x78 39993 non-null float64 x79 39994 non-null float64 x80 39991 non-null float64 x81 39996 non-null float64 x82 39992 non-null float64 x83 39995 non-null float64 x84 39997 non-null float64 x85 39986 non-null float64 x86 39989 non-null float64 x87 39996 non-null float64 x88 39996 non-null float64 x89 39989 non-null float64 x90 39993 non-null float64 x91 39996 non-null float64 x92 39993 non-null float64 x93 39993 non-null object x94 39992 non-null float64 x95 39992 non-null float64 x96 39985 non-null float64 x97 39987 non-null float64 x98 39994 non-null float64 x99 39987 non-null float64 y 40000 non-null int64 dtypes: float64(94), int64(1), object(6) memory usage: 30.8+ MB

Jake Park
  • 91
  • 1
  • 10
  • Please include a [mcve] – SuperStormer Oct 28 '18 at 21:20
  • I want to display all the string objects that are inside my data. How can I locate and print out the unique values of string data? – Jake Park Oct 28 '18 at 21:27
  • [Iterate over the rows](https://stackoverflow.com/questions/16476924/how-to-iterate-over-rows-in-a-dataframe-in-pandas) and print the values that are strings, eg `isinstance(val,str)` – SuperStormer Oct 28 '18 at 22:06

1 Answers1

1

Select all object columns, then iterate over the columns and print the unique values within each column:

for col in train.select_dtypes('object'):
    print(train[col].unique())
Peter Leimbigler
  • 10,775
  • 1
  • 23
  • 37