当前位置: 首页 > news >正文

Python酷库之旅-第三方库Pandas(005)

目录

一、用法精讲

7、pandas.read_clipboard函数

7-1、语法

7-2、参数

7-3、功能

7-4、返回值

7-5、说明

7-6、用法

7-6-1、代码示例

7-6-2、结果输出

8、pandas.DataFrame.to_clipboard函数

8-1、语法

8-2、参数

8-3、功能

8-4、返回值

8-5、说明

8-6、用法

8-6-1、代码示例

8-6-2、结果输出 

9、pandas.read_excel函数

9-1、语法

9-2、参数

9-3、功能

9-4、返回值

9-5、说明

9-6、用法

9-6-1、数据准备

9-6-2、代码示例

9-6-3、结果输出

二、推荐阅读

1、Python筑基之旅

2、Python函数之旅

3、Python算法之旅

4、Python魔法之旅

5、博客个人主页

一、用法精讲

7、pandas.read_clipboard函数
7-1、语法
# 7、pandas.read_clipboard函数
pandas.read_clipboard(sep='\\s+', dtype_backend=_NoDefault.no_default, **kwargs)
Read text from clipboard and pass to read_csv().Parses clipboard contents similar to how CSV files are parsed using read_csv().Parameters:
sepstr, default ‘\s+’
A string or regex delimiter. The default of '\\s+' denotes one or more whitespace characters.dtype_backend{‘numpy_nullable’, ‘pyarrow’}, default ‘numpy_nullable’
Back-end data type applied to the resultant DataFrame (still experimental). Behaviour is as follows:"numpy_nullable": returns nullable-dtype-backed DataFrame (default)."pyarrow": returns pyarrow-backed nullable ArrowDtype DataFrame.New in version 2.0.**kwargs
See read_csv() for the full argument list.Returns:
DataFrame
A parsed DataFrame object.
7-2、参数

7-2-1、sep(可选,默认值为'\\s+')表示使用正则表达式来匹配一个或多个空白字符(如空格、制表符等)作为字段之间的分隔符,这意味着,如果你的数据是通过空格、制表符等分隔的,你可以直接使用默认值,但如果你使用的是逗号(CSV 格式)或其他分隔符,你应该相应地更改这个参数,比如sep=','。

7-2-2、dtype_backend(可选)这个参数通常不需要用户直接设置,它是用来指定数据类型推断的后端,Pandas内部使用它来优化数据类型的推断过程。

7-2-3、**kwargs(可选)一个可变关键字参数,允许你传递额外的参数给函数,这些参数会被传递给pandas.read_csv()函数,因为read_clipboard()在内部实际上是使用read_csv()来解析剪贴板中的数据。因此,你可以传递任何read_csv()支持的参数,比如header(指定列名的行索引,默认为0,如果没有列名则为None)、index_col(用作行索引的列编号或列名列表)、dtype(指定列的数据类型)等。

7-3、功能

        从用户的系统剪贴板中读取文本数据,并将其解析为pandas DataFrame对象。

7-4、返回值

        返回值是一个pandas DataFrame对象,该对象包含了剪贴板中解析后的数据,其中每行代表数据表中的一行,每列代表数据表中的一个字段。DataFrame的索引、列名和数据类型等属性会根据剪贴板中的数据和函数的参数设置自动推断和设置。

7-5、说明

        从Pandas 1.0.0开始,dtype_backend参数已被弃用,并且可能在未来的版本中移除。在大多数情况下,用户不需要直接设置这个参数。

7-6、用法
7-6-1、代码示例
# 7、pandas.read_clipboard函数
# 7-1、先复制以下内容
# Name	Age	City
# Alice	30	New York
# Bob	25	Los Angeles
# Charlie	35	Chicago# 7-2、使用pandas.read_clipboard()函数读取剪切板的信息
import pandas as pd
# 读取剪贴板中的数据,指定分隔符为制表符
df = pd.read_clipboard(sep='\t')
# 显示 DataFrame
print(df)
7-6-2、结果输出
#       Name  Age         City  
# 0    Alice   30     New York  
# 1      Bob   25  Los Angeles  
# 2  Charlie   35        Chicago
8、pandas.DataFrame.to_clipboard函数
8-1、语法
# 8、pandas.DataFrame.to_clipboard函数
DataFrame.to_clipboard(*, excel=True, sep=None, **kwargs)
Copy object to the system clipboard.Write a text representation of object to the system clipboard. This can be pasted into Excel, for example.Parameters:
excelbool, default True
Produce output in a csv format for easy pasting into excel.True, use the provided separator for csv pasting.False, write a string representation of the object to the clipboard.sepstr, default '\t'
Field delimiter.**kwargs
These parameters will be passed to DataFrame.to_csv.
8-2、参数

8-2-1、excel(可选,默认值为True)如果为True,则尝试以Excel友好的方式复制数据,即如果可能的话,会保留多个工作表或样式。但是,请注意,由于剪贴板本身并不支持复杂的数据结构(如多个工作表或样式),因此这个参数的实际效果可能因操作系统和剪贴板支持的功能而异。在大多数情况下,将其设置为True或False对结果没有显著影响,因为剪贴板通常只接受纯文本或CSV格式的数据。

8-2-2、sep(可选,默认值为None)用于分隔DataFrame中列的分隔符。如果为None(默认值),则不会添加任何分隔符,DataFrame会以制表符分隔的格式(类似于CSV但没有引号包围字符串)复制到剪贴板。如果你想要使用逗号(,)或其他字符作为分隔符,可以指定该参数。但是,请注意,不是所有的应用程序都能很好地处理从剪贴板粘贴的自定义分隔符数据。

8-2-3、**kwargs(可选)一个可变关键字参数,允许你传递额外的参数给底层的to_csv()方法(尽管在大多数情况下,to_clipboard()方法并不直接调用to_csv(),但它们的参数在某些方面相似)。然而,对于to_clipboard()方法来说,**kwargs实际上并不接受与to_csv()相同的所有参数,因为剪贴板操作有其自身的限制和特性。

8-3、功能

        将pandas DataFrame对象的内容复制到系统的剪贴板中。

8-4、返回值

        不返回任何值(即返回值为None),它的主要作用是将DataFrame的内容复制到剪贴板,而不是返回一个新的对象或数据。

8-5、说明

        用户就可以方便地将DataFrame中的数据粘贴到其他应用程序中,如Excel、Word或其他文本编辑器,以便进一步的处理或展示。

8-6、用法
8-6-1、代码示例
# 8、pandas.DataFrame.to_clipboard函数
# 8-1、将pandas DataFrame对象的内容复制到系统的剪贴板中
import pandas as pd
# 创建一个示例 DataFrame
data = {'Name': ['Alice', 'Bob', 'Charlie'],'Age': [24, 30, 22],'City': ['New York', 'San Francisco', 'Los Angeles']}
df = pd.DataFrame(data)
# 将 DataFrame 的内容复制到剪贴板
df.to_clipboard(index=False)  # 注意:虽然这里写了 index=False,但 to_clipboard 并不接受这个参数
# 此时,你可以在其他应用程序中粘贴 DataFrame 的内容# 8-2、在打开的excel、word及编辑器中粘贴操作(注:Ctrl+V)
8-6-2、结果输出 
# Name	Age	City
# Alice	24	New York
# Bob	30	San Francisco
# Charlie	22	Los Angeles
9、pandas.read_excel函数
9-1、语法
# 9、pandas.read_excel函数
pandas.read_excel(io, sheet_name=0, *, header=0, names=None, index_col=None, usecols=None, dtype=None, engine=None, converters=None, true_values=None, false_values=None, skiprows=None, nrows=None, na_values=None, keep_default_na=True, na_filter=True, verbose=False, parse_dates=False, date_parser=_NoDefault.no_default, date_format=None, thousands=None, decimal='.', comment=None, skipfooter=0, storage_options=None, dtype_backend=_NoDefault.no_default, engine_kwargs=None)
Read an Excel file into a pandas DataFrame.Supports xls, xlsx, xlsm, xlsb, odf, ods and odt file extensions read from a local filesystem or URL. Supports an option to read a single sheet or a list of sheets.Parameters:
iostr, bytes, ExcelFile, xlrd.Book, path object, or file-like object
Any valid string path is acceptable. The string could be a URL. Valid URL schemes include http, ftp, s3, and file. For file URLs, a host is expected. A local file could be: file://localhost/path/to/table.xlsx.If you want to pass in a path object, pandas accepts any os.PathLike.By file-like object, we refer to objects with a read() method, such as a file handle (e.g. via builtin open function) or StringIO.Deprecated since version 2.1.0: Passing byte strings is deprecated. To read from a byte string, wrap it in a BytesIO object.sheet_namestr, int, list, or None, default 0
Strings are used for sheet names. Integers are used in zero-indexed sheet positions (chart sheets do not count as a sheet position). Lists of strings/integers are used to request multiple sheets. Specify None to get all worksheets.Available cases:Defaults to 0: 1st sheet as a DataFrame1: 2nd sheet as a DataFrame"Sheet1": Load sheet with name “Sheet1”[0, 1, "Sheet5"]: Load first, second and sheet named “Sheet5” as a dict of DataFrameNone: All worksheets.headerint, list of int, default 0
Row (0-indexed) to use for the column labels of the parsed DataFrame. If a list of integers is passed those row positions will be combined into a MultiIndex. Use None if there is no header.namesarray-like, default None
List of column names to use. If file contains no header row, then you should explicitly pass header=None.index_colint, str, list of int, default None
Column (0-indexed) to use as the row labels of the DataFrame. Pass None if there is no such column. If a list is passed, those columns will be combined into a MultiIndex. If a subset of data is selected with usecols, index_col is based on the subset.Missing values will be forward filled to allow roundtripping with to_excel for merged_cells=True. To avoid forward filling the missing values use set_index after reading the data instead of index_col.usecolsstr, list-like, or callable, default None
If None, then parse all columns.If str, then indicates comma separated list of Excel column letters and column ranges (e.g. “A:E” or “A,C,E:F”). Ranges are inclusive of both sides.If list of int, then indicates list of column numbers to be parsed (0-indexed).If list of string, then indicates list of column names to be parsed.If callable, then evaluate each column name against it and parse the column if the callable returns True.Returns a subset of the columns according to behavior above.dtypeType name or dict of column -> type, default None
Data type for data or columns. E.g. {‘a’: np.float64, ‘b’: np.int32} Use object to preserve data as stored in Excel and not interpret dtype, which will necessarily result in object dtype. If converters are specified, they will be applied INSTEAD of dtype conversion. If you use None, it will infer the dtype of each column based on the data.engine{‘openpyxl’, ‘calamine’, ‘odf’, ‘pyxlsb’, ‘xlrd’}, default None
If io is not a buffer or path, this must be set to identify io. Engine compatibility :openpyxl supports newer Excel file formats.calamine supports Excel (.xls, .xlsx, .xlsm, .xlsb) and OpenDocument (.ods) file formats.odf supports OpenDocument file formats (.odf, .ods, .odt).pyxlsb supports Binary Excel files.xlrd supports old-style Excel files (.xls).When engine=None, the following logic will be used to determine the engine:If path_or_buffer is an OpenDocument format (.odf, .ods, .odt), then odf will be used.Otherwise if path_or_buffer is an xls format, xlrd will be used.Otherwise if path_or_buffer is in xlsb format, pyxlsb will be used.Otherwise openpyxl will be used.convertersdict, default None
Dict of functions for converting values in certain columns. Keys can either be integers or column labels, values are functions that take one input argument, the Excel cell content, and return the transformed content.true_valueslist, default None
Values to consider as True.false_valueslist, default None
Values to consider as False.skiprowslist-like, int, or callable, optional
Line numbers to skip (0-indexed) or number of lines to skip (int) at the start of the file. If callable, the callable function will be evaluated against the row indices, returning True if the row should be skipped and False otherwise. An example of a valid callable argument would be lambda x: x in [0, 2].nrowsint, default None
Number of rows to parse.na_valuesscalar, str, list-like, or dict, default None
Additional strings to recognize as NA/NaN. If dict passed, specific per-column NA values. By default the following values are interpreted as NaN: ‘’, ‘#N/A’, ‘#N/A N/A’, ‘#NA’, ‘-1.#IND’, ‘-1.#QNAN’, ‘-NaN’, ‘-nan’, ‘1.#IND’, ‘1.#QNAN’, ‘<NA>’, ‘N/A’, ‘NA’, ‘NULL’, ‘NaN’, ‘None’, ‘n/a’, ‘nan’, ‘null’.keep_default_nabool, default True
Whether or not to include the default NaN values when parsing the data. Depending on whether na_values is passed in, the behavior is as follows:If keep_default_na is True, and na_values are specified, na_values is appended to the default NaN values used for parsing.If keep_default_na is True, and na_values are not specified, only the default NaN values are used for parsing.If keep_default_na is False, and na_values are specified, only the NaN values specified na_values are used for parsing.If keep_default_na is False, and na_values are not specified, no strings will be parsed as NaN.Note that if na_filter is passed in as False, the keep_default_na and na_values parameters will be ignored.na_filterbool, default True
Detect missing value markers (empty strings and the value of na_values). In data without any NAs, passing na_filter=False can improve the performance of reading a large file.verbosebool, default False
Indicate number of NA values placed in non-numeric columns.parse_datesbool, list-like, or dict, default False
The behavior is as follows:bool. If True -> try parsing the index.list of int or names. e.g. If [1, 2, 3] -> try parsing columns 1, 2, 3 each as a separate date column.list of lists. e.g. If [[1, 3]] -> combine columns 1 and 3 and parse as a single date column.dict, e.g. {‘foo’ : [1, 3]} -> parse columns 1, 3 as date and call result ‘foo’If a column or index contains an unparsable date, the entire column or index will be returned unaltered as an object data type. If you don`t want to parse some cells as date just change their type in Excel to “Text”. For non-standard datetime parsing, use pd.to_datetime after pd.read_excel.Note: A fast-path exists for iso8601-formatted dates.date_parserfunction, optional
Function to use for converting a sequence of string columns to an array of datetime instances. The default uses dateutil.parser.parser to do the conversion. Pandas will try to call date_parser in three different ways, advancing to the next if an exception occurs: 1) Pass one or more arrays (as defined by parse_dates) as arguments; 2) concatenate (row-wise) the string values from the columns defined by parse_dates into a single array and pass that; and 3) call date_parser once for each row using one or more strings (corresponding to the columns defined by parse_dates) as arguments.Deprecated since version 2.0.0: Use date_format instead, or read in as object and then apply to_datetime() as-needed.date_formatstr or dict of column -> format, default None
If used in conjunction with parse_dates, will parse dates according to this format. For anything more complex, please read in as object and then apply to_datetime() as-needed.New in version 2.0.0.thousandsstr, default None
Thousands separator for parsing string columns to numeric. Note that this parameter is only necessary for columns stored as TEXT in Excel, any numeric columns will automatically be parsed, regardless of display format.decimalstr, default ‘.’
Character to recognize as decimal point for parsing string columns to numeric. Note that this parameter is only necessary for columns stored as TEXT in Excel, any numeric columns will automatically be parsed, regardless of display format.(e.g. use ‘,’ for European data).New in version 1.4.0.commentstr, default None
Comments out remainder of line. Pass a character or characters to this argument to indicate comments in the input file. Any data between the comment string and the end of the current line is ignored.skipfooterint, default 0
Rows at the end to skip (0-indexed).storage_optionsdict, optional
Extra options that make sense for a particular storage connection, e.g. host, port, username, password, etc. For HTTP(S) URLs the key-value pairs are forwarded to urllib.request.Request as header options. For other URLs (e.g. starting with “s3://”, and “gcs://”) the key-value pairs are forwarded to fsspec.open. Please see fsspec and urllib for more details, and for more examples on storage options refer here.dtype_backend{‘numpy_nullable’, ‘pyarrow’}, default ‘numpy_nullable’
Back-end data type applied to the resultant DataFrame (still experimental). Behaviour is as follows:"numpy_nullable": returns nullable-dtype-backed DataFrame (default)."pyarrow": returns pyarrow-backed nullable ArrowDtype DataFrame.New in version 2.0.engine_kwargsdict, optional
Arbitrary keyword arguments passed to excel engine.Returns:
DataFrame or dict of DataFrames
DataFrame from the passed in Excel file. See notes in sheet_name argument for more information on when a dict of DataFrames is returned.
9-2、参数

9-2-1、io(必须)文件路径、文件对象或ExcelFile对象,指定要读取的Excel文件的路径或对象。

9-2-2、sheet_name(可选,默认值为0)字符串、整数、字符串列表或None,指定要读取的工作表(sheet)。如果是整数,则按位置索引(从0开始);如果是字符串,则按名称索引;如果是列表的字符串,则返回字典,其中键是工作表名,值是对应的DataFrame;如果为None,则返回所有工作表作为字典。

9-2-3、header(可选,默认值为0)指定作为列名的行,默认为0(第一行)。如果文件没有列名,则可以使用None 并通过names参数提供列名。

9-2-4、names(可选,默认值为None)列表,如果原始数据中不包含列标题,则可以通过此参数手动指定列标题。

9-2-5、index_col(可选,默认值为None)整数、字符串、序列或布尔值,用作行索引的列编号或列名。如果传递整数,则按位置索引;如果传递字符串,则按名称索引;如果是序列,则使用多个列作为多级索引;如果为False,则不使用任何列作为索引。

9-2-6、usecols(可选,默认值为None)整数、字符串、列表或可调用对象,如果为整数,则只使用这一列;如果是字符串,则只使用此名称的列;如果是列表,则使用这些索引或名称的列;如果是可调用对象,则用于选择列。

9-2-7、dtype(可选,默认值为None)类型名或字典,指定每列的数据类型。如果传递字典,则键是列名,值是类型名。

9-2-8、engine(可选,默认值为None)字符串,用于解析Excel文件的引擎。常用的有openpyxl(对于.xlsx文件)和xlrd(对于较旧的.xls文件)。注意,xlrd从版本2.0.0开始不再支持.xlsx文件。

9-2-9、converters(可选,默认值为None)字典,一个将列名映射到函数的字典,用于在读取之前转换列的值。

9-2-10、true_values/false_values(可选,默认值为None)列表样对象,用于将值转换为布尔值的序列。

9-2-11、skiprows(可选,默认值为None)列表样对象,在读取之前要跳过的行(从文件开始计数)。

9-2-12、nrows(可选,默认值为None)整数,要读取的行数(从文件开始)。

9-2-13、na_values(可选,默认值为None)标量、字符串、列表样对象或字典,用于将空值替换为NaN的额外值。

9-2-14、keep_default_na(可选,默认值为True)布尔值,如果为True,则使用pandas的默认NaN值集。

9-2-15、na_filter(可选,默认值为True)布尔值,如果为True,则尝试检测缺失值(如空字符串或仅包含空白的字符串)。

9-2-16、verbose(可选,默认值为False)布尔值,如果为True,则打印有关文件读取的额外信息。

9-2-17、parse_dates(可选,默认值为False)布尔值、列表样对象或字典,尝试将数据解析为日期。如果为True,则尝试解析所有列;如果为列表,则仅解析列表中的列;如果为字典,则字典的键是列名,值是要解析的日期格式。

9-2-18、date_parser(可选)用于解析日期的函数。

9-2-19、date_format(可选,默认值为None)日期时间对象的格式字符串。

9-2-20、thousands(可选,默认值为None)字符串,千位分隔符,如逗号(,)或点(.)。

9-2-21、decimal(可选,默认值为'.')字符串,小数点字符。

9-2-22、comment(可选,默认值为None)字符串,表示注释字符的字符串,用于跳过包含此字符的行。

9-2-23、skipfooter(可选,默认值为0)整数,在文件末尾要跳过的行数(不支持所有引擎)。

9-2-24、storage_options(可选,默认值为None)字典,对于支持的文件类型(如AWS S3、Google Cloud Storage),可以传递额外的存储选项。

9-2-25、dtype_backend(可选)这个参数通常不需要用户直接设置,它是用来指定数据类型推断的后端,Pandas内部使用它来优化数据类型的推断过程。

9-2-27、engine_kwargs(可选,默认值为None)字典,传递给Excel读取引擎的额外关键字参数。

9-3、功能

        将Excel文件中的数据读取到pandas的DataFrame对象中。

9-4、返回值

9-4-1、当只读取一个工作表时,pandas.read_excel()函数返回一个pandas DataFrame对象,该对象包含了指定工作表中的所有数据。DataFrame是pandas中用于存储和操作结构化数据的主要数据结构,它类似于Excel中的表格,有行和列。

9-4-2、当读取多个工作表时,如果sheet_name参数被设置为一个列表,包含了要读取的工作表名称或索引,则函数返回一个字典,键是工作表的名称或索引,值是该工作表对应的DataFrame对象,这样,用户就可以方便地访问和操作多个工作表中的数据。

9-5、说明

        通过这个函数,用户可以轻松地将存储在Excel表格中的数据加载到pandas的数据结构中,进而进行各种数据分析和处理操作。该函数支持从本地文件系统、URL或其他文件路径读取Excel文件,并提供了丰富的参数来自定义读取过程,如指定工作表、列名、索引列、数据类型等。

9-6、用法
9-6-1、数据准备

9-6-2、代码示例
# 9、pandas.read_excel函数
# 9-1、基本读取
import pandas as pd
# 读取 Excel 文件中的第一个工作表
df = pd.read_excel('Pandas_read_excel数据.xlsx')
print(df.head())# 9-2、读取指定工作表
import pandas as pd
# 读取名为 'Sheet2' 的工作表
df = pd.read_excel('Pandas_read_excel数据.xlsx', sheet_name='Sheet2')
print(df.head())# 9-3、指定列名和索引列
import pandas as pd
# 指定第一行作为列名,第二列作为索引列
df = pd.read_excel('Pandas_read_excel数据.xlsx', header=0, index_col=1)
print(df.head())# 9-4、读取特定列
import pandas as pd
# 只读取第1, 2, 3列
df = pd.read_excel('Pandas_read_excel数据.xlsx', usecols=[0, 1, 2])
print(df.head())# 9-5、数据类型转换
import pandas as pd
# 将第一列作为字符串读取
df = pd.read_excel('Pandas_read_excel数据.xlsx', dtype={0: str})
print(df.head())# 9-6、使用自定义缺失值
import pandas as pd
# 将 'NA' 和 'Missing' 视为缺失值
df = pd.read_excel('Pandas_read_excel数据.xlsx', na_values=['NA', 'Missing'])
print(df.head())# 9-7、跳过行和读取特定行数
import pandas as pd
# 跳过前两行,读取接下来的10行
df = pd.read_excel('Pandas_read_excel数据.xlsx', skiprows=2, nrows=10)
print(df.head())# 9-8、日期解析
import pandas as pd
# 解析第一列为日期
df = pd.read_excel('Pandas_read_excel数据.xlsx', parse_dates=[0])
print(df.head())# 9-9、读取尾部行
import pandas as pd
# 跳过最后两行
df = pd.read_excel('Pandas_read_excel数据.xlsx', skipfooter=2)
print(df.head())
9-6-3、结果输出
# 9-1、基本读取
#         生产日期 班别  机台 设备品牌      设备型号  ... 生产周期(s)  单重(g)  包装规格 当班产量(pc) 当日库存(pc)
# 0 2024-07-04  A   1  YZM  UN160SM2  ...    38.0  23.40   506     3236    12148
# 1 2024-07-04  A   3  YZM  UN160SM2  ...    38.6  15.80   612     2448   120000
# 2 2024-07-04  A   5  YZM    UN160A  ...    30.1   2.85  2500     4800     2205
# 3 2024-07-04  A   7  NaN    UN120A  ...    28.6   2.40  3500     8500    31244
# 4 2024-07-04  A   8   ZD   EM150-V  ...    33.0   4.60  3000     2800      417
#
# [5 rows x 16 columns]# 9-2、读取指定工作表
#         生产日期 班别  机台 设备品牌      设备型号  ... 生产周期(s)  单重(g)  包装规格 当班产量(pc) 当日库存(pc)
# 0 2024-07-04  A   1  YZM  UN160SM2  ...    38.0  23.40   506     3236    12148
# 1 2024-07-04  A   3  YZM  UN160SM2  ...    38.6  15.80   612     2448   120000
# 2 2024-07-04  A   5  YZM    UN160A  ...    30.1   2.85  2500     4800     2205
# 3 2024-07-04  A   7  NaN    UN120A  ...    28.6   2.40  3500     8500    31244
# 4 2024-07-04  A   8   ZD   EM150-V  ...    33.0   4.60  3000     2800      417
#
# [5 rows x 16 columns]# 9-3、指定列名和索引列
#          生产日期  机台 设备品牌      设备型号  ...  单重(g)  包装规格 当班产量(pc) 当日库存(pc)
# 班别                                ...
# A  2024-07-04   1  YZM  UN160SM2  ...  23.40   506     3236    12148
# A  2024-07-04   3  YZM  UN160SM2  ...  15.80   612     2448   120000
# A  2024-07-04   5  YZM    UN160A  ...   2.85  2500     4800     2205
# A  2024-07-04   7  NaN    UN120A  ...   2.40  3500     8500    31244
# A  2024-07-04   8   ZD   EM150-V  ...   4.60  3000     2800      417
#
# [5 rows x 15 columns]# 9-4、读取特定列
#         生产日期 班别  机台
# 0 2024-07-04  A   1
# 1 2024-07-04  A   3
# 2 2024-07-04  A   5
# 3 2024-07-04  A   7
# 4 2024-07-04  A   8# 9-5、数据类型转换
#                   生产日期 班别  机台 设备品牌  ...  单重(g)  包装规格 当班产量(pc) 当日库存(pc)
# 0  2024-07-04 00:00:00  A   1  YZM  ...  23.40   506     3236    12148
# 1  2024-07-04 00:00:00  A   3  YZM  ...  15.80   612     2448   120000
# 2  2024-07-04 00:00:00  A   5  YZM  ...   2.85  2500     4800     2205
# 3  2024-07-04 00:00:00  A   7  NaN  ...   2.40  3500     8500    31244
# 4  2024-07-04 00:00:00  A   8   ZD  ...   4.60  3000     2800      417
#
# [5 rows x 16 columns]# 9-6、使用自定义缺失值
#         生产日期 班别  机台 设备品牌      设备型号  ... 生产周期(s)  单重(g)  包装规格 当班产量(pc) 当日库存(pc)
# 0 2024-07-04  A   1  YZM  UN160SM2  ...    38.0  23.40   506     3236    12148
# 1 2024-07-04  A   3  YZM  UN160SM2  ...    38.6  15.80   612     2448   120000
# 2 2024-07-04  A   5  YZM    UN160A  ...    30.1   2.85  2500     4800     2205
# 3 2024-07-04  A   7  NaN    UN120A  ...    28.6   2.40  3500     8500    31244
# 4 2024-07-04  A   8   ZD   EM150-V  ...    33.0   4.60  3000     2800      417
#
# [5 rows x 16 columns]# 9-7、跳过行和读取特定行数
#   2024-07-04 00:00:00  A   3  YZM UN160SM2  ...  38.6  15.8   612   2448  120000
# 0          2024-07-04  A   5  YZM   UN160A  ...  30.1  2.85  2500   4800    2205
# 1          2024-07-04  A   7  NaN   UN120A  ...  28.6  2.40  3500   8500   31244
# 2          2024-07-04  A   8   ZD  EM150-V  ...  33.0  4.60  3000   2800     417
# 3          2024-07-04  A   8   ZD  EM150-V  ...  33.0  4.60  3000   3000     312
# 4          2024-07-04  A  12   HT   HA2600  ...  23.2  8.80  1000  14500  143100
#
# [5 rows x 16 columns]# 9-8、日期解析
#         生产日期 班别  机台 设备品牌      设备型号  ... 生产周期(s)  单重(g)  包装规格 当班产量(pc) 当日库存(pc)
# 0 2024-07-04  A   1  YZM  UN160SM2  ...    38.0  23.40   506     3236    12148
# 1 2024-07-04  A   3  YZM  UN160SM2  ...    38.6  15.80   612     2448   120000
# 2 2024-07-04  A   5  YZM    UN160A  ...    30.1   2.85  2500     4800     2205
# 3 2024-07-04  A   7  NaN    UN120A  ...    28.6   2.40  3500     8500    31244
# 4 2024-07-04  A   8   ZD   EM150-V  ...    33.0   4.60  3000     2800      417
#
# [5 rows x 16 columns]# 9-9、读取尾部行
#         生产日期 班别  机台 设备品牌      设备型号  ... 生产周期(s)  单重(g)  包装规格 当班产量(pc) 当日库存(pc)
# 0 2024-07-04  A   1  YZM  UN160SM2  ...    38.0  23.40   506     3236    12148
# 1 2024-07-04  A   3  YZM  UN160SM2  ...    38.6  15.80   612     2448   120000
# 2 2024-07-04  A   5  YZM    UN160A  ...    30.1   2.85  2500     4800     2205
# 3 2024-07-04  A   7  NaN    UN120A  ...    28.6   2.40  3500     8500    31244
# 4 2024-07-04  A   8   ZD   EM150-V  ...    33.0   4.60  3000     2800      417
#
# [5 rows x 16 columns]

二、推荐阅读

1、Python筑基之旅
2、Python函数之旅
3、Python算法之旅
4、Python魔法之旅
5、博客个人主页

相关文章:

Python酷库之旅-第三方库Pandas(005)

目录 一、用法精讲 7、pandas.read_clipboard函数 7-1、语法 7-2、参数 7-3、功能 7-4、返回值 7-5、说明 7-6、用法 7-6-1、代码示例 7-6-2、结果输出 8、pandas.DataFrame.to_clipboard函数 8-1、语法 8-2、参数 8-3、功能 8-4、返回值 8-5、说明 8-6、用法…...

javascripr如何设计弹出输入框并在网页内输出输入内容

javascript如何设计弹出输入对话框 这里就需要用到prompt语言 它的语法格式是 prompt(对话框内容&#xff09; 如何把在对话框里输入内容输出到网页里&#xff0c;需要先定义一个变量&#xff0c;用var或let都可以。 假定变量名为a&#xff0c;代码是 let aprompt(请输入…...

gitee代码初次上传步骤

ps. 前提是已经下载安装gitee 一、在本地项目目录下空白处右击&#xff0c;选择“Git Bash Here” 二、初始化 git init 三、添加、提交代码&#xff08;注意add与点之间的空格&#xff09; git add . git commit -m 添加注释 四、连接、推送到gitee仓库 git remote add …...

android调用openssl库

android 调用openssl库 一、openssl安装编译 下载openssl-1.1.1w.tar.gz和android-ndk-r21e-linux-x86_64.zip解压android-ndk-r21e-linux-x86_64.zip到/opt/pj_ssl目录下&#xff0c;然后配置环境 vim ~/.bashrc增加如下内容 export NDK_HOME/opt/pj_ssl/android-ndk-r21e…...

Hugging face Transformers(3)—— Tokenizer

Hugging Face 是一家在 NLP 和 AI 领域具有重要影响力的科技公司&#xff0c;他们的开源工具和社区建设为NLP研究和开发提供了强大的支持。它们拥有当前最活跃、最受关注、影响力最大的 NLP 社区&#xff0c;最新最强的 NLP 模型大多在这里发布和开源。该社区也提供了丰富的教程…...

kubernetes集群部署:环境准备及master节点部署(二)

主机名IPv4地址IPv6地址角色安装组件操作系统k8s130-node190192.168.XX.190240a:XX::190masterkubeadm、kubelet、containerdAnolis OS 8.94.19.91-28.1.an8.x86_64k8s130-node191192.168.XX.191240a:XX::191nodekubeadm、kubelet、cri-oAnolis OS 8.94.19.91-28.1.an8.x86_64k…...

第8篇 智能合约的商业应用场景解析

一、引言 在区块链技术的众多应用中,智能合约无疑是其中的一颗璀璨明珠。它通过自动化、去中心化和不可篡改的特性,为商业世界带来了革命性的变革。今天,我们将一同探索智能合约在十个不同行业中的实际应用,感受其独特的魅力。 二、智能合约的商业应用案例 供应链管理:…...

Zabbix 配置grafana对接

zabbix对接grafana简介 Zabbix与Grafana对接可以实现更加丰富和美观的数据可视化&#xff0c;可以利用Grafana强大的可视化功能来展示Zabbix收集的数据。 Grafana 本身是提供了Zabbix的对接插件&#xff0c;开箱即用&#xff0c;安装好了之后点击 enable 一下就能启用。然后就…...

三相感应电机的建模仿真(2)基于ABC相坐标系S-Fun的仿真模型

1. 概述 2. 三相感应电动机状态方程式 3. 基于S-Function的仿真模型建立 4. 瞬态分析实例 5. 总结 6. 参考文献 1. 概述 前面建立的三相感应电机在ABC相坐标系下的数学模型是一组周期性变系数微分方程&#xff08;其电感矩阵是转子位置角的函数&#xff0c;转子位置角随时…...

开源全新H5充值系统源码/自定义首页+充值页面/灵活对接上游渠道接口

开源全新H5充值系统源码&#xff0c;系统基于thinkphp框架开发&#xff0c;功能已全完善&#xff0c;可灵活对接其他上游渠道接口&#xff0c;默认对接了大猿人接口&#xff0c;另外可无限制自定义创建充值页面&#xff0c;首页支持后台自定义修改&#xff0c;支持三级分销&…...

Linux查看文件的行数,字数,字节数

介绍 在Linux系统中这统计非常方便&#xff0c;只需要简单的几个命令就可以搞定&#xff0c;这个命令就是 wc。 wc --help 用法&#xff1a;wc [选项]... [文件]...或&#xff1a;wc [选项]... --files0-fromF 输出每个指定文件的行数、单词计数和字节数&#xff0c;如果指定…...

【IO】文件操作

&#x1f970;&#x1f970;&#x1f970;来都来了&#xff0c;不妨点个关注叭&#xff01; &#x1f449;博客主页&#xff1a;欢迎各位大佬!&#x1f448; 文章目录 1. 文件1.1 认识文件1.2 分清操作的是内存还是硬盘1.3 路径1.3.1 目录结构1.3.2 相对和绝对路径 1.4 文本文件…...

代码随想录算法训练营第74天:路径总结[1]

代码随想录算法训练营第74天&#xff1a;路径总结 ‍ A * 算法精讲 &#xff08;A star算法&#xff09; 卡码网&#xff1a;126. 骑士的攻击(opens new window) 题目描述 在象棋中&#xff0c;马和象的移动规则分别是“马走日”和“象走田”。现给定骑士的起始坐标和目标…...

用 Emacs 写代码有哪些值得推荐的插件

以下是一些用于 Emacs 写代码的值得推荐的插件&#xff1a; Ido-mode&#xff1a;交互式操作模式&#xff0c;它用列出当前目录所有文件的列表来取代常规的打开文件提示符&#xff0c;能让操作更可视化&#xff0c;快速遍历文件。Smex&#xff1a;可替代普通的 M-x 提示符&…...

自定义注解-手机号验证注解

注解 package com.XX.assess.annotation;import com.XX.assess.util.MobileValidator;import javax.validation.Constraint; import javax.validation.Payload; import java.lang.annotation.*;/*** 手机号校验注解* author super*/ Retention(RetentionPolicy.RUNTIME) Targe…...

华为od-C卷200分题目5 -项目排期

华为od-C卷200分题目5 -项目排期 题目描述 项目组共有N个开发人员&#xff0c;项目经理接到了M个独立的需求&#xff0c;每个需求的工作量不同&#xff0c;且每个需求只能由一个开发人员独立完成&#xff0c;不能多人合作。 假定各个需求之间无任何先后依赖关系&#xff0c;请…...

如何使用Pip从Git仓库安装Python包:深入探索远程依赖管理

如何使用Pip从Git仓库安装Python包&#xff1a;深入探索远程依赖管理 Python的包管理工具Pip使得安装和管理Python库变得非常简单。有时&#xff0c;我们需要安装那些尚未发布到PyPI的包&#xff0c;或者想要尝试最新的开发版本。这时&#xff0c;可以直接从Git仓库安装包。本…...

计算机专业怎么选择电脑

现在高考录取结果基本已经全部出来了&#xff0c;很多同学都如愿以偿的进入到了计算机类专业&#xff0c;现在大部分同学都在为自己的大学生活做准备了&#xff0c;其中第一件事就是买电脑&#xff0c;那计算机类专业该怎么选择电脑呢&#xff1f; 计算机专业是个一类学科&…...

当前国内可用的docker加速器搜集 —— 筑梦之路

可用镜像加速器 以下地址搜集自网络&#xff0c;仅供参考&#xff0c;请自行验证。 1、https://docker.m.daocloud.io2、https://dockerpull.com3、https://atomhub.openatom.cn4、https://docker.1panel.live5、https://dockerhub.jobcher.com6、https://hub.rat.dev7、http…...

【腾讯内推】腾讯2025校招/青云计划/社招——长期有效

及时跟进进度&#xff0c;保证不让简历石沉大海&#xff01; 涵盖NLP/CV/CG/ML/多模态/数据科学/多媒体等各方向! 定向匹配优质团队/竞争力薪酬/覆盖全球工作地点! 招聘对象: 本硕博:2024年1月-2025年12月毕业的同学 目前最热岗位: 技术研究-自然语言处理 技术研究-计算机视觉 …...

集群限流sentinel实践

参考&#xff1a; 集群模式 实践 集群流控规则 其中 用一个专门的 ClusterFlowConfig 代表集群限流相关配置项&#xff0c;以与现有规则配置项分开&#xff1a; // 全局唯一的规则 ID&#xff0c;由集群限流管控端分配. private Long flowId;// 阈值模式&#xff0c;默认&…...

Flutter-实现双向PK进度条

如何实现一个双向PK进度条 在Flutter应用中&#xff0c;进度条是一个非常常见的组件。而双向PK进度条则能够展示两个对立的数值&#xff0c;如对战中的双方得分对比等。本文将介绍如何实现一个具有双向PK效果的进度条&#xff0c;并支持竖直和斜角两种过渡效果。 1. 需求 我…...

unix高级编程系列之文件I/O

背景 作为linux 开发者&#xff0c;我们不可避免会接触到文件编程。比如通过文件记录程序配置参数&#xff0c;通过字符设备与外设进行通信。因此作为合格的linux开发者&#xff0c;一定要熟练掌握文件编程。在文件编程中&#xff0c;我们一般会有两类接口函数&#xff1a;标准…...

PySide(PyQt),记录最后一次访问文件的路径

1、在同目录下用文本编辑器创建JSON文件&#xff0c;命名为setting.json&#xff0c;并输入以下内容后保存&#xff1a; { "setting": { "last_file": [ "" ] } } 2、应用脚本&#xff1a; import json …...

wordpress企业网站模板免费下载

大气上档次的wordpress企业模板&#xff0c;可以直接免费下载&#xff0c;连注册都不需要&#xff0c;网盘就可以直接下载&#xff0c;是不是嘎嘎给力呢 演示 https://www.jianzhanpress.com/?p5857 下载 链接: https://pan.baidu.com/s/1et7uMYd6--NJEWx-srMG1Q 提取码:…...

[leetcode hot 150]第一百一十七题,填充每个节点的下一个右侧节点

题目&#xff1a; 给定一个二叉树&#xff1a; struct Node {int val;Node *left;Node *right;Node *next; } 填充它的每个 next 指针&#xff0c;让这个指针指向其下一个右侧节点。如果找不到下一个右侧节点&#xff0c;则将 next 指针设置为 NULL 。 初始状态下&#x…...

Docker 入门篇(十 一)-- 网络配置总结

Docker 容器技术的核心优势之一是其轻量级的虚拟化和隔离性&#xff0c;而 Docker 网络则是实现容器间以及容器与外界通信的关键。以下是对 Docker 网络的关键知识点的总结。 一、 Docker 网络概述 Docker 网络允许容器进行相互通信以及与外部网络的连接。Docker 提供了多种网…...

【Android面试八股文】Android 有哪些存储数据的方式?

在Android平台上,有多种方式可以存储数据,每种方式都适合不同类型的数据和使用场景。以下是主要的存储数据方式: SharedPreferences(轻量级数据存储): SharedPreferences是用于存储简单键值对数据的最简单方法,适合存储用户偏好设置、配置信息等。数据以XML文件形式存储…...

3. train_encoder_decoder.py

train_encoder_decoder.py #__future__ 模块提供了一种方式&#xff0c;允许开发者在当前版本的 Python 中使用即将在将来版本中成为标准的功能和语法特性。此处为了确保代码同时兼容Python 2和Python 3版本中的print函数 from __future__ import print_function # 导入标准库…...

Hyper-V克隆虚拟机教程分享!

方法1. 使用导出导入功能克隆Hyper-V虚拟机 导出和导入是Hyper-V服务器备份和克隆的一种比较有效的方法。使用此功能&#xff0c;您可以创建Hyper-V虚拟机模板&#xff0c;其中包括软件、VM CPU、RAM和其他设备的配置&#xff0c;这有助于在Hyper-V中快速部署多个虚拟机。 在…...

QDockWidget类详解

一.QDockWidget类概述 1.QDockWidget类 QDockWidget类提供了一个特殊的窗口部件&#xff0c;它可以是被锁在QMainWindow窗口内部或者是作为顶级窗口悬浮在桌面上。 QDockWidget类提供了dock widget的概念&#xff0c;dock widget也就是我们熟悉的工具面板或者是工具窗口。Do…...

vue3.0(十六)axios详解以及完整封装方法

文章目录 axios简介1. promise2. axios特性3. 安装4. 请求方法5. 请求方法别名6. 浏览器支持情况7. 并发请求 Axios的config的配置信息1.浏览器控制台相关的请求信息&#xff1a;2.配置方法3.默认配置4.配置的优先级5.axios请求响应结果 Axios的拦截器1.请求拦截2.响应拦截3.移…...

Python用于处理 DNS 查询库之Dnspython 使用详解

概要 Dnspython 是一个开源的 Python 库,专门用于处理 DNS 查询。它被设计为既简单易用又功能强大,可以满足从简单到复杂的各种 DNS 相关需求。无论是进行基础的 DNS 查询还是进行高级的 DNS 服务器管理,dnspython 都能提供相应的功能。 这个库支持包括 A、AAAA、MX、TXT …...

Django ORM 中过滤 JSON 数据

简介 首先,我们假设您有一个名为 MyModel 的 Django 模型,它包含一个 JSONField 类型的字段,名为 data。这个 data 字段可以存储各种 JSON 格式的数据。 过滤 JSON 字段中的键值对 您可以使用双下划线 __ 语法来访问 JSON 字段中的嵌套键值对。例如: # 过滤 data 字段中 &qu…...

深入探索C语言中的结构体:定义、特性与应用

&#x1f525; 个人主页&#xff1a;大耳朵土土垚 目录 结构体的介绍结构体定义结构成员的类型结构体变量的定义和初始化结构体成员的访问结构体传参 结构体的介绍 在C语言中&#xff0c;结构体是一种用户自定义的数据类型&#xff0c;它允许开发者将不同类型的变量组合在一起…...

EDEM-FLUENT耦合报错几大原因总结(持续更新)

写在前面,本篇内容主要是来源于自己做仿真时的个人总结,以及付费请教专业老师。每个人由于工况不一样,所以报错原因千奇百怪,不能一概而论,本篇内容主要是为本专栏读者在报错时提供大致的纠错方向,从而达到少走弯路的效果,debug的过程需要大家一点点试算。问题解答在文 …...

ctfshow sql注入 web234--web241

web234 $sql "update ctfshow_user set pass {$password} where username {$username};";这里被过滤了&#xff0c;所以我们用\转义使得变为普通字符 $sql "update ctfshow_user set pass \ where username {$username};";那么这里的话 pass\ where…...

Python的招聘数据分析与可视化管理系统-计算机毕业设计源码55218

摘要 随着互联网的迅速发展&#xff0c;招聘数据在规模和复杂性上呈现爆炸式增长&#xff0c;对数据的深入分析和有效可视化成为招聘决策和招聘管理的重要手段。本论文旨在构建一个基于Python的招聘数据分析与可视化管理系统。 该平台以主流招聘平台为数据源&#xff0c;利用Py…...

使用ChatGPT写学术论文的技巧和最佳实践指南

大家好&#xff0c;感谢关注。我是七哥&#xff0c;一个在高校里不务正业&#xff0c;折腾学术科研AI实操的学术人。关于使用ChatGPT等AI学术科研的相关问题可以和作者七哥&#xff08;yida985&#xff09;交流&#xff0c;多多交流&#xff0c;相互成就&#xff0c;共同进步&a…...

多模态图像引导手术导航进展

**摘要&#xff1a;**对多模态图像分割建模、手术方案决策、手术空间位姿标定与跟踪、多模态图像配准、图像融合与显示等多模态图像引导手术导航的关键技术进行总结和分析&#xff0c;提出其进一步发展面临的挑战并展望其未来发展趋势。 **外科手术的发展历程&#xff1a;**从最…...

小程序 全局数据共享 getApp()

在小程序中&#xff0c;可以通过 getApp() 方法获取到小程序全局唯一的App实例 因此在App() 方法中添加全局共享的数据、方法&#xff0c;从而实现页面、组件的数据传值 在 app.js 文件中定义 App({// 全局共享的数据globalData:{token:},// 全局共享的方法setToken(token){//…...

第一次面试的经历(java开发实习生)

面试官的问题 我想问一下你这边有做过什么项目吗?你方便讲一下你做过的那些项目吗&#xff0c;用了什么技术栈&#xff0c;包括你负责开发的内容是什么&#xff1f;&#xff08;项目经验&#xff09;八大基本数据类型是什么&#xff1f;&#xff08;基础&#xff09;你说一下…...

GitHub Copilot API

1. 引言 GitHub Copilot&#xff1a;智能编程的革新者 在软件开发的浩瀚宇宙中&#xff0c;GitHub Copilot犹如一颗璀璨的新星&#xff0c;以其独特的魅力引领着智能编程的新纪元。作为GitHub与OpenAI合作推出的革命性工具&#xff0c;Copilot不仅仅是一个简单的代码补全插件…...

CobaltStrike的内网安全

1.上线机器的Beacon的常用命令 2.信息收集和网站克隆 3.钓鱼邮件 4.CS传递会话到MSF 5.MSF会话传递到CS 1上线机器的Beacon的常用命令 介绍&#xff1a;CobaltStrike分为服务端和客户端&#xff0c;一般我们将服务端放在kali&#xff0c;客户端可以在物理机上面&#xff0…...

Linux之进程控制(下)

目录 进程替换的概念 进程替换的函数 execl​编辑 execlp execle execv execvp execve 上期&#xff0c;我们学习了进程创建&#xff0c;进程终止和进程等待&#xff0c;今天我们要学习的是进程控制中相对重要的板块------进程替换。 进程替换的概念 在进程创建时&…...

Mac搭建anaconda环境并安装深度学习库

1. 下载anaconda安装包 根据自己的操作系统不同&#xff0c;选择不同的安装包Anaconda3-2024.06-1-MacOSX-x86_64.pkg&#xff0c;我用的还是旧的intel所以下载这个&#xff0c;https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/&#xff0c;如果mac用的是M1&#xff0…...

Linux:文件系统与日志分析

一、block与inode 1.1、概述 文件是存储在硬盘上的&#xff0c;硬盘的最小存储单位叫做“扇区”(sector)&#xff0c;每个扇区存储512字节。 一般连续八个扇区组成一个"块”(block)&#xff0c;一个块是4K大小&#xff0c;是文件存取的最小单位。 文件数据包括实际数据…...

迈阿密色主题学科 HTML5静态导航源码

源码介绍 迈阿密色主题学科 HTML5静态导航源码&#xff0c;源码直接上传可用&#xff0c;有技术的可以拿去写个后端搜索调用百度接口&#xff0c;也可用于做引导页下面加你网址添加一个A标签就行了&#xff0c;很简单&#xff0c;需要的朋友就拿去吧 界面预览 源码下载 迈阿…...

Qt 基础组件速学 鼠标和键盘事件

学习目标&#xff1a; 鼠标事件和键盘事件应用 前置环境 运行环境:qt creator 4.12 学习内容和效果演示&#xff1a; 1.鼠标事件 根据鼠标的坐标位置&#xff0c;做出对应的事件。 2.键盘事件 根据键盘的输入做出对应操作 详细主要代码 1.鼠标事件 #include "main…...

【踩坑】解决undetected-chromedriver报错cannot connect to-chrome

转载请注明出处&#xff1a;小锋学长生活大爆炸[xfxuezhagn.cn] 如果本文帮助到了你&#xff0c;欢迎[点赞、收藏、关注]哦~ 更新&#xff1a; 发现一个非常好用的项目&#xff0c;直接内置uc&#xff1a; GitHub - seleniumbase/SeleniumBase: &#x1f4ca; Pythons all-in…...