-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


Python Excel . 1:

, 27 2017 . 13:51 +
Python, . , , Excel , . . , Python pandas, openpyxl, xlrd, xlutils, pyexcel.

- Excel, , . Python , Excel, .



, , , , , Kaggle, Quandl . . - Google , . Excel .csv .

, . . ? . .
, , ( , ), , .



, -. :
  • ;
  • : , , ;
  • : , .

, . , - : , , , . , - , , .

-

Python . . , :
  • , ;
  • , . , , , . , ( ) ;
  • ;
  • , ?, $,%, ^, &, *, (,),-,#, ?,,,<,>, /, |, \, [ ,] ,{, };
  • , , NA;
  • , NA.


( ), , . , , , , , , , .

Microsoft Excel, , : .xls .xlsx ( , ( .CSV .)). , . , . .



, , .
.

, , , Python. , , .
:

# Import `os`
import os

# Retrieve current working directory (`cwd`)
cwd = os.getcwd()
cwd

# Change directory
os.chdir("/path/to/your/folder")

# List all files and directories in current directory
os.listdir('.')


, . , , . Python? :) . .

Excel

, , , , . Python 2> = 2.7.9 Python 3> = 3.4, , . , :)

:
# For Linux/OS X
pip install -U pip setuptools

# For Windows
python -m pip install -U pip setuptools


, pip, python get-pip.py, ( help).

Anaconda

Anaconda Python , Python . , data science .
, , Anakonda .

Anaconda 100 Python, R Scala , Jupyter Spyder. Jupyter Notebook, .

Anaconda .

Excel Pandas DataFrame

, , ! .

, Pandas (Pandas Python ). Pandas NumPy, . Pandas .
Pandas Anaconda, Pandas DataFrames pd.Excelfile ():
# Import pandas
import pandas as pd

# Assign spreadsheet filename to `file`
file = 'example.xlsx'

# Load spreadsheet
xl = pd.ExcelFile(file)

# Print the sheet names
print(xl.sheet_names)

# Load a sheet into a DataFrame by name: df1
df1 = xl.parse('Sheet1')


Anaconda, pip install pandas, Pandas , , .

.csv- DataFrame: read_csv (). , :
# Import pandas
import pandas as pd

# Load csv
df = pd.read_csv(example.csv)


, , , , , . , , , .

Pandas DataFrame Excel

, . Pandas DataFrames ( to_excel ). , , , XlsxWriter, .xlsx:

# Install `XlsxWriter`
pip install XlsxWriter

# Specify a writer
writer = pd.ExcelWriter('example.xlsx', engine='xlsxwriter')

# Write your DataFrame to a file
yourData.to_excel(writer, 'Sheet1')

# Save the result
writer.save()

, ExcelWriter DataFrame. , writer to_excel (), . , . ExcelWriter DataFrames .
DataFrame , XlsxWriter. , pd.ExcelWriter (), .

, .csv-, to_csv () -. , :
# Write the DataFrame to csv
df.to_csv(example.csv)


, a \ t sep. , , . .



Python . virtualenv Python: , , Python.

virtualenv, . , . virtualenv , , Python. . .
, !

# Install virtualenv
$ pip install virtualenv

# Go to the folder of your project
$ cd my_folder

# Create a virtual environment `venv`
$ virtualenv venv

# Indicate the Python interpreter to use for `venv`
$ virtualenv -p /usr/bin/python2.7 venv

# Activate `venv`
$ source venv/bin/activate

# Deactivate `venv`
$ deactivate

, , Python. , , , .
, , , , Python? . .

.
Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/331746/

:  

: [1] []
 

:
: 

: ( )

:

  URL