你看下我这个帖子是不是你想要的?https://www.cda.cn/discuss/post/details/605e80b13a599107cc1ea643
fs陈晓亮
2021-03-27
df.head( ) 是一个dataframe 类型对象
print(df.head( )) 就是print这个dataframe对象 ,print默认分隔符sep为空格,结尾end的默认值是换行符 \n, 所以print一个dataframe 无法和dataframe自己呈现的样式一模一样。
LYY202012
2021-03-27
主要是模拟生成不同的数据,这些数据可以用来研究算法模型的原理的
LYY202012
2021-03-26
这两个函数用来产生不同的数据,产生的数据主要是用来研究熟悉算法模型。
LYY202012
2021-03-26
这里 首先要理解python的引用符 “=” 的用法, pyplot.subplots() 会返回两个对象,画板 fig 与 坐标轴ax。我们可以使用一个变量去接收这两个对象,也可以使用两个变量分别接收。
fig,ax= pyplot.subplots() 这个代码就是使用两个变量去分别接收两个变量。
LYY202012
2021-03-26
如果函数或者表达式有返回值的时候会在交互式的开发工具内输出这个返回的对象,如果是在ipython 或者notebook中会显示[out] 标识
print()将数据以字符的形式输出到标准输出设备上,一般来说就是当前的交互开发工具内(如:python终端、ipython 终端或者 jupyter notebook)
两者还有一个区别,print 使用的是对象 的__str__方法 ,直接终端回车调用的是__repr__方法,当输出的是包含转义符的字符串时比较明显,print 会进行转义 而后者直接输出不做转义处理
LYY202012
2021-03-26
'economy gains 227,000 jobs in january under president trump - breitbart,katie mchugh,the u. s. economy gained 227, 000 jobs in january according to statistics released by the labor department on friday, while unemployment ticked up slightly to 4. 8 percent. [wages also increased 2. 5 percent compared to january 2016, rising six cents in december. the economy added 157, 000 jobs in december and unemployment stood at 4. 7 percent. a number of companies announced before trump’s inauguration they planned to expand in the u. s. not overseas, and hire american workers. these included ford, sap se, amazon. com, lockheed martin, gm, bayer ag, walmart, and many more. employers have also found themselves managing a tighter employment market, according to the new york times: regardless of government estimates, however, employers across sectors and across the nation have increasingly complained about the difficulty of finding workers, a competition that kept the increase in the average hourly wage ahead of a 1. 6 percent price inflation rate. “we’re still continuing to see wage pressure as the candidate market continues to shrink,” said amy glaser, senior vice president of adecco staffing usa, which has 300 branch offices. in addition to the omnipresent hunger for engineers, ms. glaser said there is a demand for those with trade skills like welding that fell into disuse during the recession, as well as warehouse and light assembly workers. “employers are getting very creative,” said ms. glaser, whose office is in lexington, ky. “we’re seeing bonuses. they have added sabbaticals to their packages, increases to stock options, free child care on site and free meals. anything to get a competitive edge. ” after election day, many companies, especially small businesses, responded with soaring optimism. during his inaugural address, trump said: “we will follow two simple rules: buy american and hire american. ”'
经过正则表达式提取出来的英文(如下)还存在数字和标点符号,是什么原因?
'economy gains jobs in january under president trump - breitbart,katie mchugh,the u. s. economy gained , jobs in january according to statistics released by the labor department on friday, while unemployment ticked up slightly to 4. 8 percent. [wages also increased 2. 5 percent compared to january , rising six cents in december. the economy added , jobs in december and unemployment stood at 4. 7 percent. a number of companies announced before trump’s inauguration they planned to expand in the u. s. not overseas, and hire american workers. these included ford, sap se, amazon. com, lockheed martin, gm, bayer ag, walmart, and many more. employers have also found themselves managing a tighter employment market, according to the new york times: regardless of government estimates, however, employers across sectors and across the nation have increasingly complained about the difficulty of finding workers, a competition that kept the increase in the average hourly wage ahead of a 1. 6 percent price inflation rate. “we’re still continuing to see wage pressure as the candidate market continues to shrink,” said amy glaser, senior vice president of adecco staffing usa, which has branch offices. in addition to the omnipresent hunger for engineers, ms. glaser said there is a demand for those with trade skills like welding that fell into disuse during the recession, as well as warehouse and light assembly workers. “employers are getting very creative,” said ms. glaser, whose office is in lexington, ky. “we’re seeing bonuses. they have added sabbaticals to their packages, increases to stock options, free child care on site and free meals. anything to get a competitive edge. ” after election day, many companies, especially small businesses, responded with soaring optimism. during his inaugural address, trump said: “we will follow two simple rules: buy american and hire american. ”'
fs陈晓亮
2021-03-26
digit_list是数字列表 chinese_list是中文列表 english_string 是英文字符串 你可以看一下
fs陈晓亮
2021-03-25
老师,追加提问:
['227,000', '227']
['川沙公路']
Economy Gains Jobs in January Under President Trump - Breitbart,,The U. S. economy gained
返回的这三个部分:假如我只要英文(或者中文),应该怎么提取?
fs陈晓亮
2021-03-25
import re str1='Economy Gains 227,000 Jobs in January Under President Trump - Breitbart,川沙公路,The U. S. economy gained 227' #先用正则表达式提取字符串里面的数字生成数字列表 pattern1=re.compile("\d+,?\d+") digit_list=pattern1.findall(str1) #再把数字从字符串里面替换为空白,然后生成新的字符串str2 str2=re.sub(pattern1,"",str1) #再把str2里面的中问找出来生成中文列表 zhongp1=re.compile('[\u4e00-\u9fa5]+') chinese_list=zhongp1.findall(str2) #再把中文从字符串里面替换为空白,然后生成新的字符串english_string english_string=re.sub(zhongp1,"",str2) #digit_list,chinese_list,english_string就是你想要的。 for i in [digit_list,chinese_list,english_string]: print(i)
fs陈晓亮
2021-03-25