I'm trying to import panel in a jupyter notebook in Hvplot but keep getting this error:
ImportError: cannot import name 'url' from 'django.conf.urls' (/Users/***/opt/anaconda3/lib/python3.9/site-packages/django/conf/urls/__init__.py)
Tried using techniques from StackOverflow but nothing works. What do I do?
This is mycode before it breaks:
import pandas as pd
import numpy as np
from django.urls import re_path as url
import panel as pn *** it breaks here
pn.extension('tabulator')
import hvplot.pandas
Related
when i try to do "from tensorflow.keras import intitializers" i get
"cannot import name 'set_policy' from 'keras.mixed_precision.policy'" this error.
Any solutions?
I would try:
tf.keras.mixed_precision.set_global_policy
or
policy = mixed_precision.Policy('mixed_float16')
mixed_precision.set_global_policy(policy)
More info you can find here:
https://www.tensorflow.org/guide/mixed_precision
go to the error directory and change the import from
from tensorflow.python.keras.mixed_precision.policy import set_policy
to
from tensorflow.python.keras.mixed_precision.policy import set_global_policy
or
from tensorflow.python.keras.mixed_precision.policy import set_policy as set_global_policy
I create a python console app that includes imports of a custom class I'm using. Everytime I run my app I get the error ModuleNotFoundError: "No module named 'DataServices'.
Can you help?
Provided below is my folder structure:
ETL
Baseball
Baseball_DataImport.py
DataServices
DataService.py
ConfigServices.py
PageDataMode.py
SportType.py
Here is the import section from the Baseball_DataImport.py file. This is the file when I run I get the error:
from bs4 import BeautifulSoup
import scrapy
import requests
import BaseballEntity
import mechanize
import re
from time import sleep
import logging
import time
import datetime
from functools import wraps
import json
import DataServices.DataService - Error occurs here
Here is my DataService.py file:
import pymongo
import json
import ConfigServices
import PageDataModel
#from SportType import SportType
class DataServices(object):
AppConfig: object
def __init__(self):
AppConfig = ConfigServices.ConfigService()
#print(AppConfig)
#def GetPagingDataBySport(self,Sport:SportType):
def GetPagingDataBySport(self):
#if Sport == SportType.BASEBALL:
pagingData = []
pagingData.append(PageDataModel.PageDataModel("", 2002, 2))
pagingData.append(PageDataModel.PageDataModel("", 2003, 2))
return pagingData
It might seem that your structure is:
Baseball
Baseball_DataImport.py
Dataservices
Dataservice.py
Maybe you need to do from Dataservices.Dataservice import DataServices
Edit:
I created the folder structure, and the method I showed you works:
Here's the implementation
Dataservice.py only contains:
class DataServices():
pass
Did you try copieing the Dataservice.py into the Projectfolder with the main.py?
My code is the following, it used to run perfectly for quite a while but suddenly got the error message. Tried other stocks data providers like Google & alpha vantage and got the same error message.
import plotly.graph_objects as go
import plotly.express as px
from datetime import datetime
import numpy as np
!pip install ffn
import ffn
import pandas_datareader.data as web
from pandas.plotting import register_matplotlib_converters
from pylab import *
import pandas as pd
import pandas_profiling
import matplotlib.pyplot as plot
from matplotlib import style
%matplotlib inline
stocks = 'alf,mrin,auud,sncr,ddd,ssnt,seac,ttd'
df = ffn.get(stocks, start='06/18/2021').to_returns().dropna()
print(df.as_format('.2%'))
df = df.apply(pd.to_numeric, errors='coerce').fillna(0)
sums = df.select_dtypes(np.number).sum()
sort_sums = sums.sort_values(ascending = False)
pd.set_option('Display.max_rows', len(stocks))
sharpe = ffn.core.calc_sharpe(df)
sharpe = sharpe.sort_values(ascending = False)
df.append({stocks: sharpe},ignore_index=True)
print(str(sort_sums.as_format('.2%')))
print(sharpe.head(10))
df.shape
I'm using Google Colaboratory
Please run the code and you will see the Error message I'm getting (I can't copy it to here).
Please help & thank you very much in advance!
I am trying to resample my dataset using bootsrtaping technique without success, my code as follow:
import pandas as pd
import numpy as np
from openpyxl import Workbook
from pandas import ExcelWriter
import matplotlib.pyplot as plt
import bootstrap as btstrap
#import scikits.bootstrap as sci
from matplotlib import pyplot as plt
import numpy.random as npr
sta_9147="//Users/talhadidi/Private/Desktop/9147.xlsx"
xlsx=pd.ExcelFile(sta_9147)
df1=pd.read_excel(xlsx,'Sheet1')
df1.columns=df1.columns.astype(str)
x_resample = btstrap(['AveOn','AveOff','AveLd','DOOR_OPEN_SEC'], n=10000)
writer=pd.ExcelWriter("/ Users/talhadidi/Private/Desktop/testt5.xlsx")
df2.to_excel(writer,'Sheet1')
writer.save()
the error i kept getting is :
TypeError: 'module' object is not callable,
could anyone help in, special thanks in advance.
I'm attempting to import a function defined in another file into the one I am working in.
The function I'm trying to import is in a file called ParallelEqns.py and looks like:
import sys
import numpy as np
import scipy as sp
import sympy as sym
import matplotlib.pyplot as plt
import os
def ParDeriv(x,p):
derivative = []
for k in range(nS):
test = x[(k-1)%nS]*(x[(k+1)%nS] - x[(k-2)%nS]) - x[(k)%nS] + p
if k == 0:
derivative = test
else:
derivative = np.vstack([derivative, test])
return derivative
The file I'm working in looks like:
import sys
import numpy as np
import scipy as sp
import sympy as sym
import matplotlib.pyplot as plt
import os
from ParallelEqns import ParDeriv
That gives me an error of "cannot import name 'ParDeriv'"
If I change the file to:
import sys
import numpy as np
import scipy as sp
import sympy as sym
import matplotlib.pyplot as plt
import os
import ParallelEqns
ParDeriv = ParallelEqns.ParDeriv
I get an error that says "module 'ParallelEqns' has no attribute 'ParDeriv'"
I've checked that both files are in the same directory. I'm not sure what I'm doing wrong here
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Edit: I've answered my own question by closing everything down and restarting python. It looks like I needed to restart python after creating the ParallelEqns.py file for it to correctly import
It turns out I just needed to restart python as I had created the file that I was trying to import after starting up python. Once I did that it worked out