In [1]:
# https://plot.ly/python/anova/

import plotly as py
import plotly.graph_objs as go
import plotly.figure_factory as ff

import numpy as np
import pandas as pd
import scipy

import statsmodels
import statsmodels.api as sm
from statsmodels.formula.api import ols

import warnings
warnings.filterwarnings("ignore", message="numpy.dtype size changed")
warnings.filterwarnings("ignore", message="numpy.ufunc size changed")

py.offline.init_notebook_mode(connected=True)



In [3]:
# 拉取数据
moore_dataset = sm.datasets.get_rdataset("Moore", "carData", cache=True)
print(moore_dataset.__doc__)
moore_df = moore_dataset.data
moore_df.rename(columns={"partner.status":"partner_status"}, inplace=True)
moore_df.head(n=10)


+-------+-----------------+
| Moore | R Documentation |
+-------+-----------------+

Status, Authoritarianism, and Conformity
----------------------------------------

Description
~~~~~~~~~~~

The ``Moore`` data frame has 45 rows and 4 columns. The data are for
subjects in a social-psychological experiment, who were faced with
manipulated disagreement from a partner of either of low or high status.
The subjects could either conform to the partner's judgment or stick
with their own judgment.

Usage
~~~~~

::

   Moore

Format
~~~~~~

This data frame contains the following columns:

partner.status
   Partner's status. A factor with levels: ``high``, ``low``.

conformity
   Number of conforming responses in 40 critical trials.

fcategory
   F-Scale Categorized. A factor with levels (note levels out of order):
   ``high``, ``low``, ``medium``.

fscore
   Authoritarianism: F-Scale score.

Source
~~~~~~

Moore, J. C., Jr. and Krupat, E. (1971) Relationship between source
status, authoritarianism and conformity in a social setting.
*Sociometry* **34**, 122–134.

Personal communication from J. Moore, Department of Sociology, York
University.

References
~~~~~~~~~~

Fox, J. (2008) *Applied Regression Analysis and Generalized Linear
Models*, Second Edition. Sage.

Fox, J. and Weisberg, S. (2011) *An R Companion to Applied Regression*,
Second Edition, Sage.

Out[3]:
partner_status conformity fcategory fscore
0 low 8 low 37
1 low 4 high 57
2 low 8 high 65
3 low 7 low 20
4 low 10 low 36
5 low 6 low 18
6 low 12 medium 51
7 low 4 medium 44
8 low 13 low 31
9 low 12 low 36

In [4]:
print("hhelo")


hhelo

In [5]:
dirs = {"aa": "bb"}

print(dirs)


{'aa': 'bb'}