0
$\begingroup$

how to see in pandas the element of a csv table with many columns (>25) which the names of its columns is more than 10 character? I have 5000 rows and 32 columns and the label of some columns are more than 10 characters. How I ca see them and work with different columns?

Excel does not work! All of the items are sloppy

Access is OK but could not detect the long labels of items!

What is your solution for it?

$\endgroup$
  • $\begingroup$ So you have dataframe with 32 columns and 5000 rows. And some of column names have more than 10 characters. You want to display them in your notebook right? Or some of column values (in rows) string objects have more than 10 characters? $\endgroup$ – Ilker Kurtulus Oct 1 '19 at 8:07
  • $\begingroup$ some of labels are more than 10 characters! I need to see them and use their label to apply some ML algorithm based on their labels! No,values are real numbers but I have problem in observation of labels! $\endgroup$ – user10296606 Oct 1 '19 at 20:28
  • $\begingroup$ Can you display some of rows as an example? $\endgroup$ – Ilker Kurtulus Oct 1 '19 at 20:52
  • $\begingroup$ ok i got the data, one last thing: label = column name right? like fastest2minwindspeed $\endgroup$ – Ilker Kurtulus Oct 2 '19 at 6:35
1
$\begingroup$

I dont know which compiler you are using but mine is jupyter.

You can make wider notebook by:

from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))

By doing that you can display more columns with df.head(). If you cant display still ("..." between columns), you can use iloc. For you data I used df.iloc[:5,:15] and df.iloc[:5,15:].

Also which is a better solution you can change pandas display options by:

pd.set_option('display.max_columns', 500)

Here is the screenshot of my notebook:

enter image description here

|improve this answer|||||
$\endgroup$
  • $\begingroup$ Can you accept my answer since your problem is solved? I will answer other questions in the comments soon. $\endgroup$ – Ilker Kurtulus Oct 2 '19 at 7:16
  • $\begingroup$ You could pass pd.set_option('display.max_columns', 500) and print(df.head()) should work? By the way I can see you are new in ds with python. I strongly recommend jupyter notebooks. $\endgroup$ – Ilker Kurtulus Oct 2 '19 at 7:23
  • $\begingroup$ In your data there are only 5 columns with na's with 26 observations. You might have a problem while reading your data. Read like this : df = pd.read_csv("/Users/.../Downloads/MetaferoWeatherData.csv", sep = ";") $\endgroup$ – Ilker Kurtulus Oct 2 '19 at 7:32
  • $\begingroup$ Thanks I can see it now! The problem was that I give it columns! What is your suggestion to model this problem based on last column? Since it is imbalanced I think I should use smote? $\endgroup$ – user10296606 Oct 2 '19 at 7:42
  • $\begingroup$ Glad it worked. Smote is good for those cases and also you can replicate negative class instances and train an ensemble model. Also you can use xgboost with tuning scale_pos_weight parameter. We are extending comments please ask new questions if you need, I will try to help you again. See you! $\endgroup$ – Ilker Kurtulus Oct 2 '19 at 7:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.