jupyter-notebook

Jupyter / IPython SList :: Obtaining non-tokenized output from the shell execute operator “!”

风格不统一 提交于 2021-01-29 15:11:47
问题 When shell commands are run within a Jupyter Notebook Python Cell , like this: output = ! some-shell-command each line emitted to the standard output ( stdout ) is captured in a list like IPython data-structure called a SList . For instance: output = !echo -e 'line1\nline2\nline3' print(output) # A IPython SList data-structure. ['line1', 'line2', 'line3'] Sometimes, however, you want to preserve the original string output format, without tokenization into a list, like this: print(output)

WinError 123 The filename, directory name, or volume label syntax is incorrect [closed]

徘徊边缘 提交于 2021-01-29 14:58:27
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 months ago . Improve this question [WinError 123] The filename, directory name, or volume label syntax is incorrect 回答1: Here in the path \f is decoded as ascii formfeed \x0c , hence the issue. Use r in front of path as r"c:\\path\to\dir" to make it raw string. 来源: https://stackoverflow.com/questions/63868961

sys.executable results are different in terminal and jupyter notebook

和自甴很熟 提交于 2021-01-29 14:42:52
问题 Because I face a problem: When from imageio import imread in my jupyter notebook, I get the error: ModuleNotFoundError: No module named 'imageio' Whereas I can successfully import in my terminal, I try to figure out what happened. When I execute sys.executable in jupyter notebook and in the terminal, the results are different: So I tried:(from https://github.com/jupyter/notebook/issues/1524#issuecomment-229713719) /Users/shinyuwu/anaconda3/bin/python -m pip install ipykernel /Users/shinyuwu

Change R version when using rpy2 package in Jupyter notebook

痞子三分冷 提交于 2021-01-29 09:23:29
问题 I want to run a piece of R code with %%R in my python3-notebook. It works, but the problem is that the R version of the notebook is the 3.6.1, while the one in my RStudio is the 4.0.1. In fact when I run R.home() the paths are different. I tried to change the version using: os.environ['R_HOME'] = '/Library/Frameworks/R.framework/Resources' %load_ext rpy2.ipython but when I call it I have a lot of errors: /Users/guglielmo/opt/anaconda3/lib/python3.7/site-packages/rpy2/rinterface/__init__.py

Python: Axis disappearing in figure when animating with celluloid

廉价感情. 提交于 2021-01-29 08:57:39
问题 I am using celluloid (https://github.com/jwkvam/celluloid) to plot a function over several years and i love it so far, it works great! I have one small problem though, the edges of my plot disappear after the first loop. I have attached images of how this looks. First loop: Second loop: As you can see the axis has disappeared. I am using cartopy and matplotlib in jupyter notebook and this is my code for the animation: # Use 'Agg' so script only displays animation in HTML import matplotlib

IPython magic-command %notebook does not work when spaces are present in path (Google Colab)

前提是你 提交于 2021-01-29 08:51:05
问题 In jupyter-lab I can use the magic command %notebook $output_file_path to save the history notebook as a jupyter notebook. When I am working with Google Colab (mounting Google Drive) the path of my notebook folder is something like: root_path = 'gdrive/My Drive/Colab Notebooks/my_working_folder/' The problem is that, as I try to save the notebook history, the space between "My" and "Drive" makes the magic command fail output_file_path = 'gdrive/My Drive/Colab Notebooks/my_working_folder/nb

Trouble reading avro files in Jupyter notebook using pyspark

邮差的信 提交于 2021-01-29 08:51:02
问题 I am trying to read an avro file in Jupyter notebook using pyspark. When I read the file i am getting an error. I have downloaded spark-avro_2.11:4.0.0.jar, i am not sure where in my code I should be inserting the avro package. Any suggestions would be great. This is an example of the code I am using to read the avro file df_avro_example = sqlContext.read.format("com.databricks.spark.avro").load("example_file.avro") This is the error I get AnalysisException: 'Failed to find data source: com

How to show all DataFrame/ table columns for wide tables while exporting as pdf from Jupyter using nbconvert?

↘锁芯ラ 提交于 2021-01-29 08:34:39
问题 This question is linked to Jupyter nbconvert LaTex Export Theme I am trying to export my Jupyter Notebook as a .pdf using nbconvert through the terminal (on Mac). I already created a .tplx template that will hide the code and show only outputs and markdowns. # this is my jupyter notebook heading pd.set_option('display.notebook_repr_html', True) pd.set_option('display.expand_frame_repr', True) pd.set_option("display.latex.repr", True) pd.set_option("display.latex.longtable", True) pd.set

Seaborn factorplot

爷,独闯天下 提交于 2021-01-29 08:31:34
问题 I am trying to create a factor plot but I am not able to change the kind of it from point to bar. How do we do that? The codes used are import numpy as np import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline sns.catplot('Sex',kind="bar",data=titanic_df) 回答1: The seaborn documentation has the exact example you are looking for. Following the documentation, if you run the below lines, it should generate the bar plot shown. import matplotlib.pyplot as plt import seaborn as sns

Jupyter interpreter permanently changed

大兔子大兔子 提交于 2021-01-29 08:10:07
问题 I was playing around with a new library which setup a new venv and interpreter (python 3.8) to the following location. import sys sys.executable '/Users/User/tensorflow_macos_venv/bin/python' While this was fine when I had activated the venv, once I deactivate it and run the Anaconda3 jupyter notebook again, I still see the same interpreter. Could someone help explain how to can I revert it back to the original? I tried going to the "change kernel" option (as mentioned in this answer) but I