However, it is difficult to do it if you use class etc. to make it object-oriented, so I am looking for a solution
class ClassName:
def __init__(self, filename):
self.data = pd.read_csv(filename)
self.filename = filename
def method(self):
data = self.data
if __init_='__main__':
def method(self):
method()
instance = ClassName(filename)
data = instance.data
It may be easier to handle if you do like this, but in data analysis it may take an unusual amount of time to worry about pollution, so it may be better not to worry about it It may be good because data can be treated as a pandas object
# -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import scipy as sp
import scipy.signal as signal
import logging
import sys
import os
import re
In addition, pyenv and anaconda were very convenient for environment construction. The environment is File execution with% run in vim and iterm Or Do all the work on ipython notebook Looks good
pd.dataframe.to_csv('default.csv')
I want to save the data of each stage with, but storage will be difficult, so TradeOff
Loops should only be used to get files
After all, numpy makes effective use of Boolean algebra arrays (validity array), and shifts the values by slicing. Worst of all in pandas, write using apply and lamda functions resample for datetime index
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
with this
logging.debug('here')
Is displayed on standard output or ipython
%matplotlib osx
Is necessary? Investigation required for plt.ion () etc.
pd.options.display.mpl_style = 'default'
plt.plot(marker='o', linestyle=None)
Or
plt.plot(linestyle='o')
Add options
for x in range(y):
plt.clf()
plt.draw() #Not drawing here
plt.pause(0.1) #Sure to draw here[s]
Need to be redrawn with
plt.show()
plt.close()
do it
plt.show()
fig, ax = plt.subplots()
for i in np.arange(count):
logging.debug(i)
ax.clear()
ax.set_title( self.title )
self.data.iloc[ i*TIME_RANGE:(i)*TIME_RANGE].plot(ax=ax, legend=False)
plt.draw()
plt.pause(PAUSE_TIME)
from mpl_toolkits.mplot3d import Axes3D
print os.getpid()
logger setting logger = logging.getLogger() logger.setLevel(logging.DEBUG)
reload reload('./filename.py')
[In] np.array([0, 1, 2])[:2]
Is
[Out] array[0, 1]
set_index
ix iloc, loc iget_value Series only irow, icol DataFrame only
data['name'] = pd.Series, list
resample
%debug
Move with u or d
s
b 12 #breakpoint
c
n
!Variable name
stats model seems to be easy to handle scipy.stats orange
Machine learning scikit-learn Scraping beautiful soup Natural language processing nltk Image processing opencv
Few people, including myself, learn both R and python in earnest (impression-based), and comparisons are unreliable, but this is a reliable article. https://chezou.wordpress.com/2014/01/18/%E7%A7%91%E5%AD%A6%E8%A8%88%E7%AE%97%E3%81%AB%E3%81%8A%E3%81%91%E3%82%8B%E5%9D%87%E8%B3%AA%E5%8C%96%E3%80%81%E3%81%82%E3%82%8B%E3%81%84%E3%81%AF%E3%81%AA%E3%81%9Cpython%E3%81%8C%E7%9D%80%E5%AE%9F/ http://postd.cc/r-vs-python-head-to-head-data-analysis/
Recommended Posts