pandas_profiling.ProfileReport(dataframe) in google colab - google-colaboratory

Why doesn't pandas_profiling.ProfileReport(dataframe) work in google colab?
Returns a type error.
TypeError: concat() got an unexpected keyword argument 'join_axes'

Just use pandas-profiling version 2.7.1 and you are good to go.Run this command in the colab !pip install pandas-profiling==2.7.1

Aishah Ismail's post on Medium may help you fix this issue.
Install the pandas-profiling package using pip.
! pip install https://github.com/pandas-profiling/pandas-profiling/archive/master.zip
Restart your kernel = Go to "Runtime" in the option menu and click "Reset All Runtimes"
Execute your code to create your dataframe and create the pandas profile.
import pandas as pd
import numpy as np
from pandas_profiling import ProfileReport
df = pd.read_excel('fileName.xlsx')
profile = ProfileReport(df)
profile.to_notebook_iframe()
You may need to pip install pandas-profiling if the import above does not work.
!pip install pandas-profiling==2.7.1 Re-execute your code after the pip install.
When you try to display the profile do not use .to_widgets()--it isn't working in Colab.
If the above doesn't work, I suggest switching to Jupyter Lab or Jupyter Notebook. The pandas profile dashboard works well in the Jupyter environment.
I hope this helps! Pandas-Profiling a wonderful EDA tool--such a time saver.

Related

Cannot import name 'to_html' from 'pandas_profiling.report' using JupyterLab

I'm new using Jupyter Lab and Pandas profiling.
I'm trying to install and import and install Pandas Profiling in a jupyter notebook. I'm able to install pandas collab using pip, but unable to import the library. The error says I cannot import name 'to_html' from 'pandas_profiling.report'.
Here's the code and the error.
Funny thing is: I also tried to run the notebook in Google Colab, but I got a different but similar error:
ImportError: cannot import name 'PandasProfiling' from 'pandas_profiling' (/usr/local/lib/python3.8/dist-packages/pandas_profiling/__init__.py)
I already tried to use Jupyter Lab and Jupyter Notebook from Anaconda and Google Colab to see if it works, but no look.
conda install -c conda-forge pandas-profiling
See this question.
from pandas_profiling import ProfileReport
https://pandas-profiling.ydata.ai/docs/master/pages/getting_started/quickstart.html
PandasProfiling object does not exist.

Importing TensorFlow "async" syntax error

I am trying to use the module imageai for a project and ran the line "from imageai.Detection import ObjectDetection". However, when I do so, this error appears:
File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tensorflow/python/pywrap_tensorflow_internal.py:114
def TFE_ContextOptionsSetAsync(arg1, async):
^
SyntaxError: invalid syntax
I found someone who had the same issue here: https://github.com/tensorflow/tensorflow/issues/20690 , but I'm not quite sure how to edit the last file of the trace where the error occurs. Does anyone have any tips on how to do this? Thanks!
I have tried looking at the above GitHub error but am not sure how to approach it.
ImageAI uses Pytorch as backend. So you need to install all the required libraries before installing and importing the imageai module.
Please use the code below to install imageai in your system:
pip install cython pillow>=7.0.0 numpy>=1.18.1 opencv-python>=4.1.2 torch>=1.9.0 --extra-index-url https://download.pytorch.org/whl/cpu torchvision>=0.10.0 --extra-index-url https://download.pytorch.org/whl/cpu pytest==7.1.3 tqdm==4.64.1 scipy>=1.7.3 matplotlib>=3.4.3 mock==4.0.3
pip install imageai --upgrade
Now, import the Object detection from imageai:
from imageai.Detection import ObjectDetection
Please refer this link for more details.
Note: You can easily install imageai in Google Colab with this code
!pip install imageai
from imageai.Detection import ObjectDetection
Hints: Please use below code to install, import and check the TensorFlow version
pip install tensorflow
import tensorflow as tf
tf.__version__

No module named 'stable_baseline3' even when it is installed in google colab

I am trying to set up stable baselines 3 in google colab. The document is connected to a local runtime on my pc through jupyter notebooks. On my pc i have installed stable baselines 3 using anaconda, and got the output saying essentially stable baselines 3 is installed. I have also run the cells:
!pip install stable-baselines3[extra]
!pip install stable-baselines3
and
!pip install stable-baselines3 --upgrade
Despite this, when i run the cell:
import stable_baseline3
from stable_baselines3 import DQN
etc...
I get the error on line 1 of ModuleNotFoundError: No module named 'stable_baseline3'. I dont understand why this would be happening, does anybody know how it could be solved?
i had the same problem
try to import stable-baselines3 first in alone cell and it should work
!pip install stable-baselines3

cannot import name 'Appender' from 'statsmodels.compat.pandas' in google colab error?

I am trying to import from pmdarima.arima import auto_arima and
from pmdarima.arima import ADFTest but it giving me error cannot import name 'Appender' from 'statsmodels.compat.pandas'
I tried !pip install pmdarima in google colab but it is still giving me error
I had the same and fixed it by downgrading scipy
pip install pmdarima scipy==1.2 -Uqq
got it from How to fix Google colab import errors on statsmodels logsumexp and factorial
A restart of the runtime environment was needed after installation.

ImportError: Install xlrd >= 0.9.0 for Excel support when using pd.readexcel to read .xlsx file : never happened before

Something strange is going on. Just today when trying to read in a dataframe from an xlsx file:
import pandas as pd
df = pd.read_excel('vlnew.xlsx',sheet_name='Sheet1')
I am getting the following error:
ImportError: Install xlrd >= 0.9.0 for Excel support
I am fully aware that plain and simple the instructions are to install xlrd, but I should not have to install xlrd when I was never getting this error before, and also, xlrd only applies to the old .xls file format. I am using .xlsx.
I can't understand why today all of a sudden this error is popping up. This is very strange indeed, at least to me.
Update:
When I execute this script in the Spyder IDE, I do not get the xlrd import error, but just today I ran this script in the Conda command prompt and only then does it report the xlrd error. Why are there inconsistencies between the Conda command prompt and Spyder IDE?
Try writing following command into the terminal
pip install xlrd
And then import the xlrd alongside with pandas
import xlrd and import pandas as pd
I was getting an error "ImportError: Install xlrd >= 1.0.0 for Excel support" on Pycharm for below code
import pandas as pd
df2 = pd.read_excel("data.xlsx")
print(df2.head(3))
print(df2.tail(3))
Solution : pip install xlrd
It resolved error after using this.
Also no need to use "import xlrd" in program
(2021.01.18)
NOTICE: the current version of "xlrd" reads only ".xls" files
to read ".xlsx" files install openpyxl package.
Just do it in your phyton frame (my is "repl.it") writing
import xlrd
or
openpyxl_
NOTICE: the current version of "xlrd" reads only ".xls" files
As mentioned by you and others correctly that xlrd needs to be installed, for using read_excel we require xlrd package.
This might be one of the possibility of compatibility difference between spyder and conda is that you might be using different conda environments for Spyder and prompt, one of which might contain xlrd package and other did not this has happens usually when we use different virtual environments for our work , it has happened to me many times.
You should try
pip install --upgrade xlrd
juste type
pip install xlrd
and use it like this
import xlrd
import pandas as pd
data=pd.read_excel('titanic3.xls')