Change default so Jupyter Notebook doesn't show heading prompt - python

Does anyone know how to make it so that Jupyter Notebook doesn't show me this prompt every time I select Heading option? I've created a jupyter_notebook_config.py file, but I didn't see an option to turn it off. I like to use headings often to break up my code and keep better documentation, but I find it annoying to constantly click OK every time.

The warning is not that headings are gone, it is that heading cells don't exist anymore. All text cells are markdown now, and you create headings by prefixing the line with a number of # symbols to indicate the heading level. When you see this dialog, it is not creating a heading cell; it is creating a markdown cell with the right number of # characters.
The way to avoid the warning is to create markdown cells and add the # characters yourself.

To not get a prompt you can just:
enter your text in the cell
hit esc to enter command mode
press 1,2,3,4,5 or 6 keys for getting a heading(1-6) respectively
simultaneously press (shift + return/enter)

Related

over writing in Spyder

Guys I am using Spyder ide, but when I go to modify a certain thing in any line it selects the letter and starts typing above it and deletes the already written code rather than spacing and typing, any solution?
I would try to hit the Insert key on your keyboard first and see if it toggles between the Insert mode and the Overtype mode:
overtype mode, in which the cursor, when typing, overwrites any text that is present in the current location; and
insert mode, where the cursor inserts a character at its current position, forcing all characters past it one position further.
The insert/overtype mode toggling is not global for the computer or
even for a single application but rather local to the text input
window in which the Insert key was pressed.

Python: replace values of a categorical variable to something else in a data frame

i have a pandas data frame in which there's a column named label of categorical type having three categories as ('>5' , '<30' , 'NO'). I want to change ('>5' , '<30') these two categories to 'yes' and i can't seem to figure out how.
I want to do this with python and also with dtale (python package).
I have managed to do it in python this way:
label_changed = {"label": {">5": "YES", "<30": "YES"}}
bp = bp.replace(label_changed)
Is there any other, more efficient, way to do this?
Also I still haven't managed to do this using dtale.
You can use replace() and pass a list with the values to be replaced and then the parameter with replacement, it's a bit tidier when you want to replace multiple values with a unique one:
to_replace = [">5","<30"]
bp = bp.replace(to_replace,"Yes")
You can also perform this in D-Tale using the "Replacements" function. You can get to this feature by clicking on the name of your column in the main data grid and then clicking "Replacements".
From there, you can either edit your column inplace or create a new column (so you don't lose your original data). Then follow these steps:
Choose "Value(s)" (which is the default)
Enter >5 in "Search For"
Keep "Raw" selected and enter Yes in the text input box
Click the "+" button
Enter <30 in "Search For"
Keep "Raw" selected and enter Yes in the text input box
Click the "+" button
Click "Replace"
Should show you the code that went into building the new column or updated column if you click the "Code Export" button from the main menu as well.

When I write " #!!!" in Spyder, it shows a tick on the left. Why?

I am using Anaconda-Spyder in learning Python. I accidentally saw a blue tick on the left when I write #!!! in my source code. Why? What does this mean?
This is a mark for you to allow to highlight places in the code with todo-like comments.
a) In Tools->Preferences dialog go to Editor -> Advanced settings tab and untick Display code annotations. Or don't untick, but find the list of comment tags that cause the blue mark to appear.
b) Don't forget to add a space after # to be pep8-compliant.

Is it possible to show the right side of a string first in an overfilled QTableWidgetItem?

The user is prompted with a file dialog and chooses a full path which is then put inside a QTableWidgetItem cell within a parent QTableWidget. Currently, when there is an overflow of text in the item and what it can display, it will show the left portion first.
If the full path is C:\Users\JohnDoe\Example_File1.txt it will show:
C:\Users\JohnDoe\Ex...
I want the user to be able to see the right portion (the file basename) first before the overflow cutoff occurs such that it will read:
...Doe\Example_File1.txt
I tried implement the following code which changed the alignment but did not appear to work as described above:
obj = self.QTable1 #A 10x3 table
for x in range(obj.rowCount()):
item = obj.item(x,2) #Change alignment for 3rd column (Where paths are stored)
item.setTextAlignment( QtCore.Qt.AlignRight)
You must textElideMode to Qt.ElideLeft and disable wordWrap:
self.QTable1.setTextElideMode(QtCore.Qt.ElideLeft)
self.QTable1.setWordWrap(False)

Creating menus using wxpython

I created a menu using:
fileMenu = wx.Menu()
fileMenu.Append(ID_NEW, "&New\tCtrl+N", "Creates a new file")
I can access New by clicking it on the menu or by clicking Ctrl+N.
My question is: What is the & stand for?
if I delete it everything is still working. However all guides still use it and none of them explain what is the purpose of it.
I've read also here:
http://wxpython.org/Phoenix/docs/html/MenuItem.html#MenuItem.SetItemLabel
"An accelerator key can be specified using the ampersand & character ... Optionally you can specify also an accelerator string appending a tab character \t followed by a valid key combination"
So according to this there is no need to use & if I use \t.
can someone confirm if my conclusion is correct? I just can't figure why I always see both... there has to be a reason why everyone are using it this way.
The & characters in menu titles indicate an accelerator that you can press while the menu is open to quickly access the item. This only works when the menu is open and focused. You'll see the underscored character in the item title as a mnemonic. Same applies to the top level menu entry as well, such as 'File' or 'Edit': by standard WIMP convention you can open said menu using Alt-F (if F is the accelerator for File) and then just as quickly press 'C' if there is an accelerator for C in that menu. Quick and very little known these days.
The \t means a tab in traditional context and in menu items it will make a global shortcut in your frame that you can press without the menu being active.
The shortcut letter following & will be accessible only from the menu.
The \tCtrl+N is available from the entire app, and the short-cut is displayed next to the menu item.

Categories

Resources