 pandas: powerful Python data analysis toolkit - 1.3.2libraries like etree and lxml to build the necessary document and not by string concatenation or regex adjustments. Always remember XML is a special text file with markup rules. • With very large XML files (several set a new column color to ‘green’ when the second column has ‘Z’. You can do the following: In [208]: df = pd.DataFrame({'col1': list('ABBC'), 'col2': list('ZZXY')}) In [209]: df['color'] = np.where(df['col2'] where(df['col2'] == 'Z', 'green', 'red') In [210]: df Out[210]: col1 col2 color 0 A Z green 1 B Z green 2 B X red 3 C Y red If you have multiple conditions, you can use numpy.select() to achieve that.0 码力 | 3509 页 | 14.01 MB | 1 年前3 pandas: powerful Python data analysis toolkit - 1.3.2libraries like etree and lxml to build the necessary document and not by string concatenation or regex adjustments. Always remember XML is a special text file with markup rules. • With very large XML files (several set a new column color to ‘green’ when the second column has ‘Z’. You can do the following: In [208]: df = pd.DataFrame({'col1': list('ABBC'), 'col2': list('ZZXY')}) In [209]: df['color'] = np.where(df['col2'] where(df['col2'] == 'Z', 'green', 'red') In [210]: df Out[210]: col1 col2 color 0 A Z green 1 B Z green 2 B X red 3 C Y red If you have multiple conditions, you can use numpy.select() to achieve that.0 码力 | 3509 页 | 14.01 MB | 1 年前3
 pandas: powerful Python data analysis toolkit - 1.3.3libraries like etree and lxml to build the necessary document and not by string concatenation or regex adjustments. Always remember XML is a special text file with markup rules. • With very large XML files (several set a new column color to ‘green’ when the second column has ‘Z’. You can do the following: In [208]: df = pd.DataFrame({'col1': list('ABBC'), 'col2': list('ZZXY')}) In [209]: df['color'] = np.where(df['col2'] where(df['col2'] == 'Z', 'green', 'red') In [210]: df Out[210]: col1 col2 color 0 A Z green 1 B Z green 2 B X red 3 C Y red If you have multiple conditions, you can use numpy.select() to achieve that.0 码力 | 3603 页 | 14.65 MB | 1 年前3 pandas: powerful Python data analysis toolkit - 1.3.3libraries like etree and lxml to build the necessary document and not by string concatenation or regex adjustments. Always remember XML is a special text file with markup rules. • With very large XML files (several set a new column color to ‘green’ when the second column has ‘Z’. You can do the following: In [208]: df = pd.DataFrame({'col1': list('ABBC'), 'col2': list('ZZXY')}) In [209]: df['color'] = np.where(df['col2'] where(df['col2'] == 'Z', 'green', 'red') In [210]: df Out[210]: col1 col2 color 0 A Z green 1 B Z green 2 B X red 3 C Y red If you have multiple conditions, you can use numpy.select() to achieve that.0 码力 | 3603 页 | 14.65 MB | 1 年前3
 pandas: powerful Python data analysis toolkit - 1.3.4libraries like etree and lxml to build the necessary document and not by string concatenation or regex adjustments. Always remember XML is a special text file with markup rules. • With very large XML files (several set a new column color to ‘green’ when the second column has ‘Z’. You can do the following: In [208]: df = pd.DataFrame({'col1': list('ABBC'), 'col2': list('ZZXY')}) In [209]: df['color'] = np.where(df['col2'] where(df['col2'] == 'Z', 'green', 'red') In [210]: df Out[210]: col1 col2 color 0 A Z green 1 B Z green 2 B X red 3 C Y red If you have multiple conditions, you can use numpy.select() to achieve that.0 码力 | 3605 页 | 14.68 MB | 1 年前3 pandas: powerful Python data analysis toolkit - 1.3.4libraries like etree and lxml to build the necessary document and not by string concatenation or regex adjustments. Always remember XML is a special text file with markup rules. • With very large XML files (several set a new column color to ‘green’ when the second column has ‘Z’. You can do the following: In [208]: df = pd.DataFrame({'col1': list('ABBC'), 'col2': list('ZZXY')}) In [209]: df['color'] = np.where(df['col2'] where(df['col2'] == 'Z', 'green', 'red') In [210]: df Out[210]: col1 col2 color 0 A Z green 1 B Z green 2 B X red 3 C Y red If you have multiple conditions, you can use numpy.select() to achieve that.0 码力 | 3605 页 | 14.68 MB | 1 年前3
 pandas: powerful Python data analysis toolkit - 1.4.2libraries like etree and lxml to build the necessary document and not by string concatenation or regex adjustments. Always remember XML is a special text file with markup rules. • With very large XML files (several set a new column color to ‘green’ when the second column has ‘Z’. You can do the following: In [210]: df = pd.DataFrame({'col1': list('ABBC'), 'col2': list('ZZXY')}) In [211]: df['color'] = np.where(df['col2'] where(df['col2'] == 'Z', 'green', 'red') In [212]: df Out[212]: col1 col2 color 0 A Z green 1 B Z green 2 B X red 3 C Y red If you have multiple conditions, you can use numpy.select() to achieve that.0 码力 | 3739 页 | 15.24 MB | 1 年前3 pandas: powerful Python data analysis toolkit - 1.4.2libraries like etree and lxml to build the necessary document and not by string concatenation or regex adjustments. Always remember XML is a special text file with markup rules. • With very large XML files (several set a new column color to ‘green’ when the second column has ‘Z’. You can do the following: In [210]: df = pd.DataFrame({'col1': list('ABBC'), 'col2': list('ZZXY')}) In [211]: df['color'] = np.where(df['col2'] where(df['col2'] == 'Z', 'green', 'red') In [212]: df Out[212]: col1 col2 color 0 A Z green 1 B Z green 2 B X red 3 C Y red If you have multiple conditions, you can use numpy.select() to achieve that.0 码力 | 3739 页 | 15.24 MB | 1 年前3
 pandas: powerful Python data analysis toolkit - 1.4.4libraries like etree and lxml to build the necessary document and not by string concatenation or regex adjustments. Always remember XML is a special text file with markup rules. • With very large XML files (several set a new column color to ‘green’ when the second column has ‘Z’. You can do the following: In [210]: df = pd.DataFrame({'col1': list('ABBC'), 'col2': list('ZZXY')}) In [211]: df['color'] = np.where(df['col2'] pandas: powerful Python data analysis toolkit, Release 1.4.4 (continued from previous page) col1 col2 color 0 A Z green 1 B Z green 2 B X red 3 C Y red If you have multiple conditions, you can use numpy0 码力 | 3743 页 | 15.26 MB | 1 年前3 pandas: powerful Python data analysis toolkit - 1.4.4libraries like etree and lxml to build the necessary document and not by string concatenation or regex adjustments. Always remember XML is a special text file with markup rules. • With very large XML files (several set a new column color to ‘green’ when the second column has ‘Z’. You can do the following: In [210]: df = pd.DataFrame({'col1': list('ABBC'), 'col2': list('ZZXY')}) In [211]: df['color'] = np.where(df['col2'] pandas: powerful Python data analysis toolkit, Release 1.4.4 (continued from previous page) col1 col2 color 0 A Z green 1 B Z green 2 B X red 3 C Y red If you have multiple conditions, you can use numpy0 码力 | 3743 页 | 15.26 MB | 1 年前3
 pandas: powerful Python data analysis toolkit - 1.5.0rc0libraries like etree and lxml to build the necessary document and not by string concatenation or regex adjustments. Always remember XML is a special text file with markup rules. • With very large XML files (several set a new column color to ‘green’ when the second column has ‘Z’. You can do the following: In [210]: df = pd.DataFrame({'col1': list('ABBC'), 'col2': list('ZZXY')}) In [211]: df['color'] = np.where(df['col2'] where(df['col2'] == 'Z', 'green', 'red') In [212]: df Out[212]: col1 col2 color 0 A Z green 1 B Z green 2 B X red 3 C Y red If you have multiple conditions, you can use numpy.select() to achieve that.0 码力 | 3943 页 | 15.73 MB | 1 年前3 pandas: powerful Python data analysis toolkit - 1.5.0rc0libraries like etree and lxml to build the necessary document and not by string concatenation or regex adjustments. Always remember XML is a special text file with markup rules. • With very large XML files (several set a new column color to ‘green’ when the second column has ‘Z’. You can do the following: In [210]: df = pd.DataFrame({'col1': list('ABBC'), 'col2': list('ZZXY')}) In [211]: df['color'] = np.where(df['col2'] where(df['col2'] == 'Z', 'green', 'red') In [212]: df Out[212]: col1 col2 color 0 A Z green 1 B Z green 2 B X red 3 C Y red If you have multiple conditions, you can use numpy.select() to achieve that.0 码力 | 3943 页 | 15.73 MB | 1 年前3
 pandas: powerful Python data analysis toolkit - 1.1.1MultiIndex.from_arrays([colors, foods], names=['color', 'food']) In [220]: df = pd.DataFrame(np.random.randn(n, 2), index=index) In [221]: df Out[221]: 0 1 color food red ham 0.194889 -0.381994 ham 0.318587 095031 -0.270099 eggs -0.707140 -0.773882 eggs 0.229453 0.304418 In [222]: df.query('color == "red"') Out[222]: 0 1 color food red ham 0.194889 -0.381994 ham 0.318587 2.089075 eggs -0.728293 -0.090255 pandas: powerful Python data analysis toolkit - 1.1.1MultiIndex.from_arrays([colors, foods], names=['color', 'food']) In [220]: df = pd.DataFrame(np.random.randn(n, 2), index=index) In [221]: df Out[221]: 0 1 color food red ham 0.194889 -0.381994 ham 0.318587 095031 -0.270099 eggs -0.707140 -0.773882 eggs 0.229453 0.304418 In [222]: df.query('color == "red"') Out[222]: 0 1 color food red ham 0.194889 -0.381994 ham 0.318587 2.089075 eggs -0.728293 -0.090255- ----> 1 df.iloc[5].plot.bar() NameError: name 'df' is not defined In [19]: plt.axhline(0, color='k'); 2.14. Visualization 593 pandas: powerful Python data analysis toolkit, Release 1.1.1 Calling 0 码力 | 3231 页 | 10.87 MB | 1 年前3
 pandas: powerful Python data analysis toolkit - 1.1.0MultiIndex.from_arrays([colors, foods], names=['color', 'food']) In [220]: df = pd.DataFrame(np.random.randn(n, 2), index=index) In [221]: df Out[221]: 0 1 color food red ham 0.194889 -0.381994 ham 0.318587 095031 -0.270099 eggs -0.707140 -0.773882 eggs 0.229453 0.304418 In [222]: df.query('color == "red"') Out[222]: 0 1 color food red ham 0.194889 -0.381994 ham 0.318587 2.089075 eggs -0.728293 -0.090255 pandas: powerful Python data analysis toolkit - 1.1.0MultiIndex.from_arrays([colors, foods], names=['color', 'food']) In [220]: df = pd.DataFrame(np.random.randn(n, 2), index=index) In [221]: df Out[221]: 0 1 color food red ham 0.194889 -0.381994 ham 0.318587 095031 -0.270099 eggs -0.707140 -0.773882 eggs 0.229453 0.304418 In [222]: df.query('color == "red"') Out[222]: 0 1 color food red ham 0.194889 -0.381994 ham 0.318587 2.089075 eggs -0.728293 -0.090255- ----> 1 df.iloc[5].plot.bar() NameError: name 'df' is not defined In [19]: plt.axhline(0, color='k'); 2.14. Visualization 593 pandas: powerful Python data analysis toolkit, Release 1.1.0 Calling 0 码力 | 3229 页 | 10.87 MB | 1 年前3
 pandas: powerful Python data analysis toolkit - 1.2.0set a new column color to ‘green’ when the second column has ‘Z’. You can do the following: In [208]: df = pd.DataFrame({'col1': list('ABBC'), 'col2': list('ZZXY')}) In [209]: df['color'] = np.where(df['col2'] where(df['col2'] == 'Z', 'green', 'red') In [210]: df Out[210]: col1 col2 color 0 A Z green 1 B Z green 2 B X red 3 C Y red If you have multiple conditions, you can use numpy.select() to achieve that. Say corresponding to three condi- tions there are three choice of colors, with a fourth color as a fallback, you can do the following. In [211]: conditions = [ .....: (df['col2'] == 'Z') & (df['col1']0 码力 | 3313 页 | 10.91 MB | 1 年前3 pandas: powerful Python data analysis toolkit - 1.2.0set a new column color to ‘green’ when the second column has ‘Z’. You can do the following: In [208]: df = pd.DataFrame({'col1': list('ABBC'), 'col2': list('ZZXY')}) In [209]: df['color'] = np.where(df['col2'] where(df['col2'] == 'Z', 'green', 'red') In [210]: df Out[210]: col1 col2 color 0 A Z green 1 B Z green 2 B X red 3 C Y red If you have multiple conditions, you can use numpy.select() to achieve that. Say corresponding to three condi- tions there are three choice of colors, with a fourth color as a fallback, you can do the following. In [211]: conditions = [ .....: (df['col2'] == 'Z') & (df['col1']0 码力 | 3313 页 | 10.91 MB | 1 年前3
 pandas: powerful Python data analysis toolkit - 1.2.3set a new column color to ‘green’ when the second column has ‘Z’. You can do the following: In [208]: df = pd.DataFrame({'col1': list('ABBC'), 'col2': list('ZZXY')}) In [209]: df['color'] = np.where(df['col2'] where(df['col2'] == 'Z', 'green', 'red') In [210]: df Out[210]: col1 col2 color 0 A Z green 1 B Z green 2 B X red 3 C Y red If you have multiple conditions, you can use numpy.select() to achieve that. Say corresponding to three condi- tions there are three choice of colors, with a fourth color as a fallback, you can do the following. In [211]: conditions = [ .....: (df['col2'] == 'Z') & (df['col1']0 码力 | 3323 页 | 12.74 MB | 1 年前3 pandas: powerful Python data analysis toolkit - 1.2.3set a new column color to ‘green’ when the second column has ‘Z’. You can do the following: In [208]: df = pd.DataFrame({'col1': list('ABBC'), 'col2': list('ZZXY')}) In [209]: df['color'] = np.where(df['col2'] where(df['col2'] == 'Z', 'green', 'red') In [210]: df Out[210]: col1 col2 color 0 A Z green 1 B Z green 2 B X red 3 C Y red If you have multiple conditions, you can use numpy.select() to achieve that. Say corresponding to three condi- tions there are three choice of colors, with a fourth color as a fallback, you can do the following. In [211]: conditions = [ .....: (df['col2'] == 'Z') & (df['col1']0 码力 | 3323 页 | 12.74 MB | 1 年前3
共 32 条
- 1
- 2
- 3
- 4













