Python from or import

I've done so well about importing again,,

I want to use a function called datetime () to start this! It started from that place.

(When I think about it now, this function was a songwriter ...)

import datetime

** Sure! !! ** **

image.png

why! !! !! !!

I thought about it.

from datetime import datetime

myDate = datetime(2017,1,1)

You can do this! !!

It seems that there are various patterns, but it seems good to remember the following

** ① import pandas as pd pattern **

This loads the Pandas module and makes it available under the name pd. There are a lot of functions in the Pandas module, like (DataFrame) You can use it by prefixing it with pd in the form of pd.DataFrame ().

** ② from sklearn.linear_model import Logistic Regression pattern **

This is a pinpoint, in a module called sklearn.linear_model, Make it possible to use a function called LogisticRegression. (It seems that there is a concept of submodule, but it is omitted) So you can just use it in the form of Logistic Regression (iroiro)

If you don't use so many different types of functions like scikit-learn, This is probably more suitable. (And vice versa. Pd.hoge)


The following article was insanely detailed. Be careful not to lose track of what you want to know because you are too detailed! https://qiita.com/suzuki-hoge/items/f951d56290617df4279e

By the way, black magic

from pandas import *

There seems to be some. This will allow you to use the functions in the pandas module without a prefix! Convenient! However, it seems that it is better to stop it because the function names collide and something bad happens. I think so.

P.S. The datetime () that got me hooked this time was quite complicated, and it was a pattern that there is a function called datetime in the datetime module.

import datetime
myDate = datetime.datetime(2016,1,1)
import datetime as dt
myDate = dt.datetime(2016,1,1)

This is okay!

Recommended Posts

Python from or import
From sys import stderr or import sys → sys.stderr
python> link> from __future__ import absolute_import
About Python, from and import, as
Python module import
Import python script
sql from python
MeCab from Python
Summarize Python import
Use thingsspeak from python
Python> list> extend () or + =
Touch MySQL from Python 3
Operate Filemaker from Python
Use fluentd from python
Access bitcoind from python
Changes from Python 3.0 to Python 3.5
Changes from Python 2 to Python 3.0
[Python] Convert from DICOM to PNG or CSV
Import Excel file from Python (register to DB)
python original module import
python autotest or sniffer
Use MySQL from Python
Run python from excel
Install python from source
Execute command from Python
Operate neutron from Python!
Use MySQL from Python
Operate LXC from Python
Manipulate riak from python
Force Python from Fortran
Use BigQuery from python.
Import tsv with Python
Execute command from python
Memorandum @ Python OR Seminar
[Python] Read From Stdin
Use mecab-ipadic-neologd from python
MessagePack-Call Python (or Python to Ruby) methods from Ruby using RPC
Import classes in jar files directly from Python scripts
Task registration or Notification in Python in Outlook (from VIM)
Flatten using Python yield from
Call CPLEX from Python (DO cplex)
Deep Python learned from DEAP
Post from Python to Slack
How Python module import works
Grammar features added from Python3.6
Python 3.4 or later standard pip
Cheating from PHP to Python
Dynamically import scripts in Python
Import vtk with brew python
Make MeCab available from Python3
Information obtained from tweet_id (Python)
OCR from PDF in Python
Run illustrator script from python
Use MySQL from Anaconda (python)
Anaconda updated from 4.2.0 to 4.3.0 (python3.5 updated to python3.6)
Study from Python Hour4: Object-oriented ②
Query Athena from Lambda Python
Access Oracle DB from Python
Memorandum @ Python OR Seminar: matplotlib
Study from Python Hour3: Functions
Start / stop GCE from python