There are plenty of 'pretty-printing' visualization libraries for Javascript. E.g. those listed here.
Googling for 'python visualization libraries' only turns up stuff like VTK... moreThere are plenty of 'pretty-printing' visualization libraries for Javascript. E.g. those listed here.
Googling for 'python visualization libraries' only turns up stuff like VTK and mayavi, which are primarily more for no-nonsense scientific use.
So, do you know of any Python libraries similar to those Javascript ones in the above link? I particularly like the Javascript Infovis Toolkit.
I have a list of strings containing arbitary phone numbers in python. The extension is an optional part.
st =
My objective is to segregate the phone numbers so that I can... moreI have a list of strings containing arbitary phone numbers in python. The extension is an optional part.
st =
My objective is to segregate the phone numbers so that I can isolate each individual group viz. '800', '555', '1212' and the optional '1234'.
I have tried out the following code.
p1 = re.compile(r'(\d{3}).*(\d{3}).*(\d{4}).*(\d{4})?')
step1 =
p2 = re.compile(r'(\d{3})(\d{3})(\d{4})(\d{4})?')
step2 =
p1 and p2 being the two patterns to fetch the desired output.
for i in range(len(step2)):
print step2
Since I am a newbie, I wish to get suggestions if there are better ways to tacle such problems or some best practices followed in Python community. Thanks in advance.
I just got into SQL to do some data science and was wondering why my code was running but not affecting the MySQL database in any way. I am using pycharm and the MySQLdb module.
... moreI just got into SQL to do some data science and was wondering why my code was running but not affecting the MySQL database in any way. I am using pycharm and the MySQLdb module.
import MySQLdb
db = MySQLdb.connect(host="localhost",
user="root",
passwd="********", #Password blocked
db="test")
cur = db.cursor()
cur.execute("SELECT * FROM movies")
cur.execute("Update movies set genre = 'action' where id = 1")
for row in cur.fetchall() :
print row, " ", row, " ", row
My code runs and returns no errors, but when I delete the
cur.execute("Update movies set genre = 'action' where id = 1")
line it just prints out the table the as it was before. Just for reference, here is the table:
1 Interstellar sci-fi
2 Thor: Ragnarok action
3 Thor: The Dark World action
How can I make the commands in python actually affect the table? Thank you so much for your help! less
__future__ frequently appears in Python modules. I do not understand what __future__ is for and how/when to use it even after reading the Python's __future__ doc.Can anyone... more__future__ frequently appears in Python modules. I do not understand what __future__ is for and how/when to use it even after reading the Python's __future__ doc.Can anyone explain with examples?A few answers regarding the basic usage of __future__ I've received seemed correct.However, I need to understand one more thing regarding how __future__ works:The most confusing concept for me is how a current python release includes features for future releases, and how a program using a feature from a future release can be be compiled successfully in the current version of Python.I am guessing that the current release is packaged with potential features for the future. However, the features are available only by using __future__ because they are not the current standard. Let me know if I am right. less
Can any one tell my what that part (town = thisLine)exactly do?
def get_list_of_university_towns():
'''Returns a DataFrame of towns and the states they are in from the... moreCan any one tell my what that part (town = thisLine)exactly do?
def get_list_of_university_towns():
'''Returns a DataFrame of towns and the states they are in from the
university_towns.txt list. The format of the DataFrame should be:
DataFrame( [ , ,
columns= )
The following cleaning needs to be done:
1. For "State", removing characters from "[" to the end.
2. For "RegionName", when applicable, removing every character from " (" to the end.
3. Depending on how you read the data, you may need to remove newline character '\n'. '''
data =
state = None
state_towns =
with open('university_towns.txt') as file:
for line in file:
thisLine = line
if thisLine == '':
state = thisLine
continue
if '(' in line:
town = thisLine
state_towns.append()
else:
town = thisLine
state_towns.append()
data.append(thisLine)
df = pd.DataFrame(state_towns,columns = )
return df
I tried to install XGBoost package in python. I am using windows os, 64bits . I have gone through following.
The package directory states that xgboost is unstable for windows and... moreI tried to install XGBoost package in python. I am using windows os, 64bits . I have gone through following.
The package directory states that xgboost is unstable for windows and is disabled: pip installation on windows is currently disabled for further invesigation, please install from github. https://pypi.python.org/pypi/xgboost/
I am not well versed in Visual Studio, facing problem building XGBoost. I am missing opportunities to utilize xgboost package in data science.
Please guide, so that I can import the XGBoost package in python.
Thanks less
I'm looking for information on how should a Python Machine Learning project be organized. For Python usual projects there is Cookiecutter and for R ProjectTemplate.
This is my... moreI'm looking for information on how should a Python Machine Learning project be organized. For Python usual projects there is Cookiecutter and for R ProjectTemplate.
This is my current folder structure, but I'm mixing Jupyter Notebooks with actual Python code and it does not seems very clear.
.
├── cache
├── data
├── my_module
├── logs
├── notebooks
├── scripts
├── snippets
└── tools
I work in the scripts folder and currently adding all the functions in files under my_module, but that leads to errors loading data(relative/absolute paths) and other problems.
I could not find proper best practices or good examples on this topic besides this kaggle competition solution and some Notebooks that have all the functions condensed at the start of such Notebook. less
Every semester I have at least one Python student who uses dict.update() to add a single key/value pair,... moreEvery semester I have at least one Python student who uses dict.update() to add a single key/value pair, viz.:
mydict.update({'newkey':'newvalue'})
instead of
mydict = 'newvalue'
I don't teach this method and I don't know where they're finding examples of this, but I tell them not to do it because it's less efficient (presumably creates a new 2-element dict) and because it's nonstandard.
Honestly, I can understand the desire to use a visible method rather than this syntax - it perhaps feels more consistent with other method calls. But I think it looks like a newbie approach.
Is there any wisdom anyone has to offer on this point? less
I am relatively new Data science in python and was exploring some competition on data science, i am getting confused with "Training data Set" and "Test Data Set" . Some projects... moreI am relatively new Data science in python and was exploring some competition on data science, i am getting confused with "Training data Set" and "Test Data Set" . Some projects have merged both and some they have kept separate. What is the rationale behind having two data sets. Any advise will be helpful thanks
In Python, Suppose there is a dictionary named... moreIn Python, Suppose there is a dictionary named fruits:
fruits={
"apple":5,
"orange":7,
"mango":9
}
On reading the dictionary items, it should create 3 lists having same name as dictionary keys viz. apple, orange and mango and size of theses lists should be 5, 7 and 9 respectively. The elements of these lists should be given from the user through console.
so I happened to receive an xlms file that contains names of individuals with different titles such as Mr, Ms, Dr, Mrs, Judge etc. However some of these names contains multiple... moreso I happened to receive an xlms file that contains names of individuals with different titles such as Mr, Ms, Dr, Mrs, Judge etc. However some of these names contains multiple titles within one name example "Mr Mrs Ronderval", "Dr Rev Johns Mr" etc. So am trying to remove all of them except for one, hence the final result should be Mr Ronderval or Mrs Ronderval, Dr Johns or Rev Johns or Mr Johns any of them will be fine. So far what i have done is to convert the strings into a list of lists such as name_list = , and have a list of titles title=. So i tried to iterate through the name_list removing all values from titles and the result obviously is "Roderval" and "Johns" but i want atleast one title to be left in the name Mr Ronderval or Mrs Ronderval, Dr Johns or Rev Johns or Mr Johns. How do i go about this?
Here is my code using list comprehension
name_list=
So I wrote this code to return back every string in the given lst: list once. Here is my code
def make_unique(lst: list):
s =
for x in... moreSo I wrote this code to return back every string in the given lst: list once. Here is my code
def make_unique(lst: list):
s =
for x in lst:
if lst.count(x) == 1:
s.append(x)
else:
return(x)
return s
When I put in the input:
print(make_unique(lst=))
The output returns
row
but I want my output to return
which is basically all the strings in the list printed once. How can I do this??
I have two python files namely abc.py and xyz.pyabc.py contains two function viz func_1() and func_2()My directory structure is as follows
db_ops /
__init__.py
... moreI have two python files namely abc.py and xyz.pyabc.py contains two function viz func_1() and func_2()My directory structure is as follows
db_ops /
__init__.py
abc.py
xyz.py
Now in xyz.py I have the following import method
from db_ops.abc import func_1
When I run xyz.py I am getting error as
ModuleNotFoundError: No module named 'db_ops'
Am I missing out anything?P.S. I am using Windows 10
Good afternoon.
I have this question I am trying to solve using "panda" statistical data structures and related syntax from the Python scripting language. I am already graduated... moreGood afternoon.
I have this question I am trying to solve using "panda" statistical data structures and related syntax from the Python scripting language. I am already graduated from a US university and employed while currently taking the Coursera.org course of "Python for Data Science" just for professional development, which is offered online at Coursera's platform by the University of Michigan. I'm not sharing answers to anyone either as I abide by Coursera's Honor Code.
First, I was given this panda dataframe chart concerning Olympic medals won by countries around the world:
# Summer Gold Silver Bronze Total # Winter Gold.1 Silver.1 Bronze.1 Total.1 # Games Gold.2 Silver.2 Bronze.2 Combined total ID